feat: add filterable countRows to remote API (#1169)

This commit is contained in:
QianZhu
2024-04-01 14:31:15 -07:00
committed by Weston Pace
parent e5bfec4318
commit 2f89fc26f1
2 changed files with 6 additions and 7 deletions

View File

@@ -454,8 +454,10 @@ export class RemoteTable<T = number[]> implements Table<T> {
}
}
async countRows (): Promise<number> {
const result = await this._client.post(`/v1/table/${this._name}/describe/`)
async countRows (filter?: string): Promise<number> {
const result = await this._client.post(`/v1/table/${this._name}/count_rows/`, {
predicate: filter
})
return (await result.body())?.stats?.num_rows
}

View File

@@ -499,11 +499,8 @@ class RemoteTable(Table):
)
def count_rows(self, filter: Optional[str] = None) -> int:
# payload = {"filter": filter}
# self._conn._client.post(f"/v1/table/{self._name}/count_rows/", data=payload)
return NotImplementedError(
"count_rows() is not yet supported on the LanceDB cloud"
)
payload = {"predicate": filter}
self._conn._client.post(f"/v1/table/{self._name}/count_rows/", data=payload)
def add_columns(self, transforms: Dict[str, str]):
raise NotImplementedError(