@lancedb/lancedb 0.21.4-beta.0 → 0.22.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -128,48 +128,82 @@ export declare abstract class Connection {
128
128
  *
129
129
  * Tables will be returned in lexicographical order.
130
130
  * @param {Partial<TableNamesOptions>} options - options to control the
131
- * paging / start point
131
+ * paging / start point (backwards compatibility)
132
132
  *
133
133
  */
134
134
  abstract tableNames(options?: Partial<TableNamesOptions>): Promise<string[]>;
135
+ /**
136
+ * List all the table names in this database.
137
+ *
138
+ * Tables will be returned in lexicographical order.
139
+ * @param {string[]} namespace - The namespace to list tables from (defaults to root namespace)
140
+ * @param {Partial<TableNamesOptions>} options - options to control the
141
+ * paging / start point
142
+ *
143
+ */
144
+ abstract tableNames(namespace?: string[], options?: Partial<TableNamesOptions>): Promise<string[]>;
135
145
  /**
136
146
  * Open a table in the database.
137
147
  * @param {string} name - The name of the table
148
+ * @param {string[]} namespace - The namespace of the table (defaults to root namespace)
149
+ * @param {Partial<OpenTableOptions>} options - Additional options
138
150
  */
139
- abstract openTable(name: string, options?: Partial<OpenTableOptions>): Promise<Table>;
151
+ abstract openTable(name: string, namespace?: string[], options?: Partial<OpenTableOptions>): Promise<Table>;
140
152
  /**
141
153
  * Creates a new Table and initialize it with new data.
142
154
  * @param {object} options - The options object.
143
155
  * @param {string} options.name - The name of the table.
144
156
  * @param {Data} options.data - Non-empty Array of Records to be inserted into the table
157
+ * @param {string[]} namespace - The namespace to create the table in (defaults to root namespace)
145
158
  *
146
159
  */
147
160
  abstract createTable(options: {
148
161
  name: string;
149
162
  data: Data;
150
- } & Partial<CreateTableOptions>): Promise<Table>;
163
+ } & Partial<CreateTableOptions>, namespace?: string[]): Promise<Table>;
151
164
  /**
152
165
  * Creates a new Table and initialize it with new data.
153
166
  * @param {string} name - The name of the table.
154
167
  * @param {Record<string, unknown>[] | TableLike} data - Non-empty Array of Records
155
168
  * to be inserted into the table
169
+ * @param {Partial<CreateTableOptions>} options - Additional options (backwards compatibility)
156
170
  */
157
171
  abstract createTable(name: string, data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
172
+ /**
173
+ * Creates a new Table and initialize it with new data.
174
+ * @param {string} name - The name of the table.
175
+ * @param {Record<string, unknown>[] | TableLike} data - Non-empty Array of Records
176
+ * to be inserted into the table
177
+ * @param {string[]} namespace - The namespace to create the table in (defaults to root namespace)
178
+ * @param {Partial<CreateTableOptions>} options - Additional options
179
+ */
180
+ abstract createTable(name: string, data: Record<string, unknown>[] | TableLike, namespace?: string[], options?: Partial<CreateTableOptions>): Promise<Table>;
158
181
  /**
159
182
  * Creates a new empty Table
160
183
  * @param {string} name - The name of the table.
161
184
  * @param {Schema} schema - The schema of the table
185
+ * @param {Partial<CreateTableOptions>} options - Additional options (backwards compatibility)
162
186
  */
163
187
  abstract createEmptyTable(name: string, schema: import("./arrow").SchemaLike, options?: Partial<CreateTableOptions>): Promise<Table>;
188
+ /**
189
+ * Creates a new empty Table
190
+ * @param {string} name - The name of the table.
191
+ * @param {Schema} schema - The schema of the table
192
+ * @param {string[]} namespace - The namespace to create the table in (defaults to root namespace)
193
+ * @param {Partial<CreateTableOptions>} options - Additional options
194
+ */
195
+ abstract createEmptyTable(name: string, schema: import("./arrow").SchemaLike, namespace?: string[], options?: Partial<CreateTableOptions>): Promise<Table>;
164
196
  /**
165
197
  * Drop an existing table.
166
198
  * @param {string} name The name of the table to drop.
199
+ * @param {string[]} namespace The namespace of the table (defaults to root namespace).
167
200
  */
168
- abstract dropTable(name: string): Promise<void>;
201
+ abstract dropTable(name: string, namespace?: string[]): Promise<void>;
169
202
  /**
170
203
  * Drop all tables in the database.
204
+ * @param {string[]} namespace The namespace to drop tables from (defaults to root namespace).
171
205
  */
172
- abstract dropAllTables(): Promise<void>;
206
+ abstract dropAllTables(namespace?: string[]): Promise<void>;
173
207
  }
174
208
  /** @hideconstructor */
175
209
  export declare class LocalConnection extends Connection {
@@ -179,16 +213,17 @@ export declare class LocalConnection extends Connection {
179
213
  isOpen(): boolean;
180
214
  close(): void;
181
215
  display(): string;
182
- tableNames(options?: Partial<TableNamesOptions>): Promise<string[]>;
183
- openTable(name: string, options?: Partial<OpenTableOptions>): Promise<Table>;
216
+ tableNames(namespaceOrOptions?: string[] | Partial<TableNamesOptions>, options?: Partial<TableNamesOptions>): Promise<string[]>;
217
+ openTable(name: string, namespace?: string[], options?: Partial<OpenTableOptions>): Promise<Table>;
184
218
  private getStorageOptions;
185
219
  createTable(nameOrOptions: string | ({
186
220
  name: string;
187
221
  data: Data;
188
- } & Partial<CreateTableOptions>), data?: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
189
- createEmptyTable(name: string, schema: import("./arrow").SchemaLike, options?: Partial<CreateTableOptions>): Promise<Table>;
190
- dropTable(name: string): Promise<void>;
191
- dropAllTables(): Promise<void>;
222
+ } & Partial<CreateTableOptions>), dataOrNamespace?: Record<string, unknown>[] | TableLike | string[], namespaceOrOptions?: string[] | Partial<CreateTableOptions>, options?: Partial<CreateTableOptions>): Promise<Table>;
223
+ private _createTableImpl;
224
+ createEmptyTable(name: string, schema: import("./arrow").SchemaLike, namespaceOrOptions?: string[] | Partial<CreateTableOptions>, options?: Partial<CreateTableOptions>): Promise<Table>;
225
+ dropTable(name: string, namespace?: string[]): Promise<void>;
226
+ dropAllTables(namespace?: string[]): Promise<void>;
192
227
  }
193
228
  /**
194
229
  * Takes storage options and makes all the keys snake case.
@@ -51,11 +51,24 @@ class LocalConnection extends Connection {
51
51
  display() {
52
52
  return this.inner.display();
53
53
  }
54
- async tableNames(options) {
55
- return this.inner.tableNames(options?.startAfter, options?.limit);
54
+ async tableNames(namespaceOrOptions, options) {
55
+ // Detect if first argument is namespace array or options object
56
+ let namespace;
57
+ let tableNamesOptions;
58
+ if (Array.isArray(namespaceOrOptions)) {
59
+ // First argument is namespace array
60
+ namespace = namespaceOrOptions;
61
+ tableNamesOptions = options;
62
+ }
63
+ else {
64
+ // First argument is options object (backwards compatibility)
65
+ namespace = undefined;
66
+ tableNamesOptions = namespaceOrOptions;
67
+ }
68
+ return this.inner.tableNames(namespace ?? [], tableNamesOptions?.startAfter, tableNamesOptions?.limit);
56
69
  }
57
- async openTable(name, options) {
58
- const innerTable = await this.inner.openTable(name, cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
70
+ async openTable(name, namespace, options) {
71
+ const innerTable = await this.inner.openTable(name, namespace ?? [], cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
59
72
  return new table_1.LocalTable(innerTable);
60
73
  }
61
74
  getStorageOptions(options) {
@@ -75,42 +88,76 @@ class LocalConnection extends Connection {
75
88
  }
76
89
  return cleanseStorageOptions(options?.storageOptions);
77
90
  }
78
- async createTable(nameOrOptions, data, options) {
91
+ async createTable(nameOrOptions, dataOrNamespace, namespaceOrOptions, options) {
79
92
  if (typeof nameOrOptions !== "string" && "name" in nameOrOptions) {
80
- const { name, data, ...options } = nameOrOptions;
81
- return this.createTable(name, data, options);
93
+ // First overload: createTable(options, namespace?)
94
+ const { name, data, ...createOptions } = nameOrOptions;
95
+ const namespace = dataOrNamespace;
96
+ return this._createTableImpl(name, data, namespace, createOptions);
97
+ }
98
+ // Second overload: createTable(name, data, namespace?, options?)
99
+ const name = nameOrOptions;
100
+ const data = dataOrNamespace;
101
+ // Detect if third argument is namespace array or options object
102
+ let namespace;
103
+ let createOptions;
104
+ if (Array.isArray(namespaceOrOptions)) {
105
+ // Third argument is namespace array
106
+ namespace = namespaceOrOptions;
107
+ createOptions = options;
108
+ }
109
+ else {
110
+ // Third argument is options object (backwards compatibility)
111
+ namespace = undefined;
112
+ createOptions = namespaceOrOptions;
82
113
  }
114
+ return this._createTableImpl(name, data, namespace, createOptions);
115
+ }
116
+ async _createTableImpl(name, data, namespace, options) {
83
117
  if (data === undefined) {
84
118
  throw new Error("data is required");
85
119
  }
86
120
  const { buf, mode } = await parseTableData(data, options);
87
121
  const storageOptions = this.getStorageOptions(options);
88
- const innerTable = await this.inner.createTable(nameOrOptions, buf, mode, storageOptions);
122
+ const innerTable = await this.inner.createTable(name, buf, mode, namespace ?? [], storageOptions);
89
123
  return new table_1.LocalTable(innerTable);
90
124
  }
91
- async createEmptyTable(name, schema, options) {
92
- let mode = options?.mode ?? "create";
93
- const existOk = options?.existOk ?? false;
125
+ async createEmptyTable(name, schema, namespaceOrOptions, options) {
126
+ // Detect if third argument is namespace array or options object
127
+ let namespace;
128
+ let createOptions;
129
+ if (Array.isArray(namespaceOrOptions)) {
130
+ // Third argument is namespace array
131
+ namespace = namespaceOrOptions;
132
+ createOptions = options;
133
+ }
134
+ else {
135
+ // Third argument is options object (backwards compatibility)
136
+ namespace = undefined;
137
+ createOptions = namespaceOrOptions;
138
+ }
139
+ let mode = createOptions?.mode ?? "create";
140
+ const existOk = createOptions?.existOk ?? false;
94
141
  if (mode === "create" && existOk) {
95
142
  mode = "exist_ok";
96
143
  }
97
144
  let metadata = undefined;
98
- if (options?.embeddingFunction !== undefined) {
99
- const embeddingFunction = options.embeddingFunction;
145
+ if (createOptions?.embeddingFunction !== undefined) {
146
+ const embeddingFunction = createOptions.embeddingFunction;
100
147
  const registry = (0, registry_1.getRegistry)();
101
148
  metadata = registry.getTableMetadata([embeddingFunction]);
102
149
  }
103
- const storageOptions = this.getStorageOptions(options);
150
+ const storageOptions = this.getStorageOptions(createOptions);
104
151
  const table = (0, arrow_2.makeEmptyTable)(schema, metadata);
105
152
  const buf = await (0, arrow_2.fromTableToBuffer)(table);
106
- const innerTable = await this.inner.createEmptyTable(name, buf, mode, storageOptions);
153
+ const innerTable = await this.inner.createEmptyTable(name, buf, mode, namespace ?? [], storageOptions);
107
154
  return new table_1.LocalTable(innerTable);
108
155
  }
109
- async dropTable(name) {
110
- return this.inner.dropTable(name);
156
+ async dropTable(name, namespace) {
157
+ return this.inner.dropTable(name, namespace ?? []);
111
158
  }
112
- async dropAllTables() {
113
- return this.inner.dropAllTables();
159
+ async dropAllTables(namespace) {
160
+ return this.inner.dropAllTables(namespace ?? []);
114
161
  }
115
162
  }
116
163
  exports.LocalConnection = LocalConnection;
package/dist/native.d.ts CHANGED
@@ -86,6 +86,7 @@ export interface ClientConfig {
86
86
  retryConfig?: RetryConfig
87
87
  timeoutConfig?: TimeoutConfig
88
88
  extraHeaders?: Record<string, string>
89
+ idDelimiter?: string
89
90
  }
90
91
  export interface RerankerCallbacks {
91
92
  rerankHybrid: (...args: any[]) => any
@@ -316,7 +317,7 @@ export class Connection {
316
317
  isOpen(): boolean
317
318
  close(): void
318
319
  /** List all tables in the dataset. */
319
- tableNames(startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
320
+ tableNames(namespace: Array<string>, startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
320
321
  /**
321
322
  * Create table from a Apache Arrow IPC (file) buffer.
322
323
  *
@@ -325,12 +326,12 @@ export class Connection {
325
326
  * - buf: The buffer containing the IPC file.
326
327
  *
327
328
  */
328
- createTable(name: string, buf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
329
- createEmptyTable(name: string, schemaBuf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
330
- openTable(name: string, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
329
+ createTable(name: string, buf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
330
+ createEmptyTable(name: string, schemaBuf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
331
+ openTable(name: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
331
332
  /** Drop table with the name. Or raise an error if the table does not exist. */
332
- dropTable(name: string): Promise<void>
333
- dropAllTables(): Promise<void>
333
+ dropTable(name: string, namespace: Array<string>): Promise<void>
334
+ dropAllTables(namespace: Array<string>): Promise<void>
334
335
  }
335
336
  export class Index {
336
337
  static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, numBits?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.21.4-beta.0",
14
+ "version": "0.22.0-beta.0",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -100,14 +100,14 @@
100
100
  "reflect-metadata": "^0.2.2"
101
101
  },
102
102
  "optionalDependencies": {
103
- "@lancedb/lancedb-darwin-x64": "0.21.4-beta.0",
104
- "@lancedb/lancedb-darwin-arm64": "0.21.4-beta.0",
105
- "@lancedb/lancedb-linux-x64-gnu": "0.21.4-beta.0",
106
- "@lancedb/lancedb-linux-arm64-gnu": "0.21.4-beta.0",
107
- "@lancedb/lancedb-linux-x64-musl": "0.21.4-beta.0",
108
- "@lancedb/lancedb-linux-arm64-musl": "0.21.4-beta.0",
109
- "@lancedb/lancedb-win32-x64-msvc": "0.21.4-beta.0",
110
- "@lancedb/lancedb-win32-arm64-msvc": "0.21.4-beta.0"
103
+ "@lancedb/lancedb-darwin-x64": "0.22.0-beta.0",
104
+ "@lancedb/lancedb-darwin-arm64": "0.22.0-beta.0",
105
+ "@lancedb/lancedb-linux-x64-gnu": "0.22.0-beta.0",
106
+ "@lancedb/lancedb-linux-arm64-gnu": "0.22.0-beta.0",
107
+ "@lancedb/lancedb-linux-x64-musl": "0.22.0-beta.0",
108
+ "@lancedb/lancedb-linux-arm64-musl": "0.22.0-beta.0",
109
+ "@lancedb/lancedb-win32-x64-msvc": "0.22.0-beta.0",
110
+ "@lancedb/lancedb-win32-arm64-msvc": "0.22.0-beta.0"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "apache-arrow": ">=15.0.0 <=18.1.0"