From 2f89fc26f12a95d9c7d34aa60928eb2a868dc55a Mon Sep 17 00:00:00 2001 From: QianZhu Date: Mon, 1 Apr 2024 14:31:15 -0700 Subject: [PATCH] feat: add filterable countRows to remote API (#1169) --- node/src/remote/index.ts | 6 ++++-- python/python/lancedb/remote/table.py | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/node/src/remote/index.ts b/node/src/remote/index.ts index 78807b14..81dc8b54 100644 --- a/node/src/remote/index.ts +++ b/node/src/remote/index.ts @@ -454,8 +454,10 @@ export class RemoteTable implements Table { } } - async countRows (): Promise { - const result = await this._client.post(`/v1/table/${this._name}/describe/`) + async countRows (filter?: string): Promise { + const result = await this._client.post(`/v1/table/${this._name}/count_rows/`, { + predicate: filter + }) return (await result.body())?.stats?.num_rows } diff --git a/python/python/lancedb/remote/table.py b/python/python/lancedb/remote/table.py index 65bc450d..c1428a0b 100644 --- a/python/python/lancedb/remote/table.py +++ b/python/python/lancedb/remote/table.py @@ -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(