mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-25 07:28:39 +00:00
feat: builder API for list_tables, deprecate table_names
`Connection::list_tables` took a `lance_namespace::models::ListTablesRequest` directly, so its generated shape -- including `identity`, `context` and `include_declared`, none of which lancedb reads -- was part of the public API, and Node had no binding at all. Replaces it with a `ListTablesBuilder` carrying `page_token`, `limit` and `namespace`, matching every other operation on `Connection`. This is a breaking change for Rust callers. Node gains `listTables` with `ListTablesOptions` and `ListTablesResponse`; Python's public API is unchanged, since it already had `list_tables` everywhere. `table_names` and `TableNamesBuilder` are deprecated. Its `start_after` takes a table name rather than an opaque token, which cannot be pushed down into a store that resumes from a continuation token. Also fixes the page boundary in `ListingDatabase::list_tables`: the token was the first name of the next page while resuming skips names at or before the token, so one table was dropped per boundary. Walking `[a, b, c, d, e]` with a limit of 2 returned `[a, b, d, e]`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,12 @@ pub struct ListNamespacesResponse {
|
||||
pub page_token: Option<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct ListTablesResponse {
|
||||
pub tables: Vec<String>,
|
||||
pub page_token: Option<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct CreateNamespaceResponse {
|
||||
pub properties: Option<HashMap<String, String>>,
|
||||
@@ -189,6 +195,8 @@ impl Connection {
|
||||
|
||||
/// List all tables in the dataset.
|
||||
#[napi(catch_unwind)]
|
||||
// Deprecated in favour of `list_tables`, but still exposed to JavaScript.
|
||||
#[allow(deprecated)]
|
||||
pub async fn table_names(
|
||||
&self,
|
||||
namespace_path: Option<Vec<String>>,
|
||||
@@ -206,6 +214,29 @@ impl Connection {
|
||||
op.execute().await.default_error()
|
||||
}
|
||||
|
||||
/// List a page of tables in the database.
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn list_tables(
|
||||
&self,
|
||||
namespace_path: Option<Vec<String>>,
|
||||
page_token: Option<String>,
|
||||
limit: Option<u32>,
|
||||
) -> napi::Result<ListTablesResponse> {
|
||||
let mut op = self.get_inner()?.list_tables();
|
||||
op = op.namespace(namespace_path.unwrap_or_default());
|
||||
if let Some(page_token) = page_token {
|
||||
op = op.page_token(page_token);
|
||||
}
|
||||
if let Some(limit) = limit {
|
||||
op = op.limit(limit);
|
||||
}
|
||||
let resp = op.execute().await.default_error()?;
|
||||
Ok(ListTablesResponse {
|
||||
tables: resp.tables,
|
||||
page_token: resp.page_token,
|
||||
})
|
||||
}
|
||||
|
||||
/// Create table from a Apache Arrow IPC (file) buffer.
|
||||
///
|
||||
/// Parameters:
|
||||
|
||||
Reference in New Issue
Block a user