fix saas open_table and table_names issues (#640)

- added check whether a table exists in SaaS open_table
- remove prefilter not supported warning in SaaS search
- fixed issues for SaaS table_names
This commit is contained in:
QianZhu
2023-11-07 17:34:38 -08:00
committed by GitHub
parent 9d895801f2
commit 662968559d
3 changed files with 16 additions and 12 deletions

View File

@@ -155,13 +155,10 @@ class RestfulLanceDBClient:
self, limit: int, page_token: Optional[str] = None
) -> Iterable[str]:
"""List all tables in the database."""
try:
json = await self.get(
"/v1/table/", {"limit": limit, "page_token": page_token}
)
return json["tables"]
except StopAsyncIteration:
return []
if page_token is None:
page_token = ""
json = await self.get("/v1/table/", {"limit": limit, "page_token": page_token})
return json["tables"]
@_check_not_closed
async def query(self, table_name: str, query: VectorQuery) -> VectorQueryResult:

View File

@@ -13,6 +13,7 @@
import asyncio
import inspect
import logging
import uuid
from typing import Iterable, List, Optional, Union
from urllib.parse import urlparse
@@ -62,7 +63,7 @@ class RemoteDBConnection(DBConnection):
Parameters
----------
last_token: str
page_token: str
The last token to start the new page.
Returns
@@ -95,8 +96,16 @@ class RemoteDBConnection(DBConnection):
"""
from .table import RemoteTable
# TODO: check if table exists
# check if table exists
try:
self._loop.run_until_complete(
self._client.post(f"/v1/table/{name}/describe/")
)
except Exception:
logging.error(
"Table {name} does not exist."
"Please first call db.create_table({name}, data)"
)
return RemoteTable(self, name)
@override

View File

@@ -99,8 +99,6 @@ class RemoteTable(Table):
return LanceVectorQueryBuilder(self, query, vector_column_name)
def _execute_query(self, query: Query) -> pa.Table:
if query.prefilter:
raise NotImplementedError("Cloud support for prefiltering is coming soon")
result = self._conn._client.query(self._name, query)
return self._conn._loop.run_until_complete(result).to_arrow()