@lancedb/lancedb 0.19.1-beta.1 → 0.19.1-beta.2

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.
package/dist/arrow.js CHANGED
@@ -542,8 +542,9 @@ class PathTree {
542
542
  function transposeData(data, field, path = []) {
543
543
  if (field.type instanceof apache_arrow_1.Struct) {
544
544
  const childFields = field.type.children;
545
+ const fullPath = [...path, field.name];
545
546
  const childVectors = childFields.map((child) => {
546
- return transposeData(data, child, [...path, child.name]);
547
+ return transposeData(data, child, fullPath);
547
548
  });
548
549
  const structData = (0, apache_arrow_1.makeData)({
549
550
  type: field.type,
@@ -556,7 +557,11 @@ function transposeData(data, field, path = []) {
556
557
  const values = data.map((datum) => {
557
558
  let current = datum;
558
559
  for (const key of valuesPath) {
559
- if (isObject(current) && Object.hasOwn(current, key)) {
560
+ if (current == null) {
561
+ return null;
562
+ }
563
+ if (isObject(current) &&
564
+ (Object.hasOwn(current, key) || key in current)) {
560
565
  current = current[key];
561
566
  }
562
567
  else {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Connection } from "./connection";
2
2
  import { ConnectionOptions } from "./native.js";
3
- export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, } from "./native.js";
3
+ export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, MergeResult, AddResult, AddColumnsResult, AlterColumnsResult, DeleteResult, DropColumnsResult, UpdateResult, } from "./native.js";
4
4
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
5
5
  export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
6
6
  export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, FullTextQueryType, } from "./query";
package/dist/merge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Data, Schema } from "./arrow";
2
- import { NativeMergeInsertBuilder } from "./native";
2
+ import { MergeResult, NativeMergeInsertBuilder } from "./native";
3
3
  /** A builder used to create and run a merge insert operation */
4
4
  export declare class MergeInsertBuilder {
5
5
  #private;
@@ -48,7 +48,7 @@ export declare class MergeInsertBuilder {
48
48
  /**
49
49
  * Executes the merge insert operation
50
50
  *
51
- * Nothing is returned but the `Table` is updated
51
+ * @returns {Promise<MergeResult>} the merge result
52
52
  */
53
- execute(data: Data): Promise<void>;
53
+ execute(data: Data): Promise<MergeResult>;
54
54
  }
package/dist/merge.js CHANGED
@@ -58,7 +58,7 @@ class MergeInsertBuilder {
58
58
  /**
59
59
  * Executes the merge insert operation
60
60
  *
61
- * Nothing is returned but the `Table` is updated
61
+ * @returns {Promise<MergeResult>} the merge result
62
62
  */
63
63
  async execute(data) {
64
64
  let schema;
@@ -70,7 +70,7 @@ class MergeInsertBuilder {
70
70
  schema = this.#schema;
71
71
  }
72
72
  const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
73
- await this.#native.execute(buffer);
73
+ return await this.#native.execute(buffer);
74
74
  }
75
75
  }
76
76
  exports.MergeInsertBuilder = MergeInsertBuilder;
package/dist/native.d.ts CHANGED
@@ -230,6 +230,31 @@ export interface Version {
230
230
  timestamp: number
231
231
  metadata: Record<string, string>
232
232
  }
233
+ export interface UpdateResult {
234
+ rowsUpdated: number
235
+ version: number
236
+ }
237
+ export interface AddResult {
238
+ version: number
239
+ }
240
+ export interface DeleteResult {
241
+ version: number
242
+ }
243
+ export interface MergeResult {
244
+ version: number
245
+ numInsertedRows: number
246
+ numUpdatedRows: number
247
+ numDeletedRows: number
248
+ }
249
+ export interface AddColumnsResult {
250
+ version: number
251
+ }
252
+ export interface AlterColumnsResult {
253
+ version: number
254
+ }
255
+ export interface DropColumnsResult {
256
+ version: number
257
+ }
233
258
  export interface ConnectionOptions {
234
259
  /**
235
260
  * (For LanceDB OSS only): The interval, in seconds, at which to check for
@@ -313,7 +338,7 @@ export class NativeMergeInsertBuilder {
313
338
  whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
314
339
  whenNotMatchedInsertAll(): NativeMergeInsertBuilder
315
340
  whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
316
- execute(buf: Buffer): Promise<void>
341
+ execute(buf: Buffer): Promise<MergeResult>
317
342
  }
318
343
  export class Query {
319
344
  onlyIf(predicate: string): void
@@ -380,20 +405,20 @@ export class Table {
380
405
  close(): void
381
406
  /** Return Schema as empty Arrow IPC file. */
382
407
  schema(): Promise<Buffer>
383
- add(buf: Buffer, mode: string): Promise<void>
408
+ add(buf: Buffer, mode: string): Promise<AddResult>
384
409
  countRows(filter?: string | undefined | null): Promise<number>
385
- delete(predicate: string): Promise<void>
410
+ delete(predicate: string): Promise<DeleteResult>
386
411
  createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null, waitTimeoutS?: number | undefined | null): Promise<void>
387
412
  dropIndex(indexName: string): Promise<void>
388
413
  prewarmIndex(indexName: string): Promise<void>
389
414
  waitForIndex(indexNames: Array<string>, timeoutS: number): Promise<void>
390
415
  stats(): Promise<TableStatistics>
391
- update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<bigint>
416
+ update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<UpdateResult>
392
417
  query(): Query
393
418
  vectorSearch(vector: Float32Array): VectorQuery
394
- addColumns(transforms: Array<AddColumnsSql>): Promise<void>
395
- alterColumns(alterations: Array<ColumnAlteration>): Promise<void>
396
- dropColumns(columns: Array<string>): Promise<void>
419
+ addColumns(transforms: Array<AddColumnsSql>): Promise<AddColumnsResult>
420
+ alterColumns(alterations: Array<ColumnAlteration>): Promise<AlterColumnsResult>
421
+ dropColumns(columns: Array<string>): Promise<DropColumnsResult>
397
422
  version(): Promise<number>
398
423
  checkout(version: number): Promise<void>
399
424
  checkoutTag(tag: string): Promise<void>
package/dist/table.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Table as ArrowTable, Data, DataType, IntoVector, Schema } from "./arrow";
2
2
  import { IndexOptions } from "./indices";
3
3
  import { MergeInsertBuilder } from "./merge";
4
- import { AddColumnsSql, IndexConfig, IndexStatistics, OptimizeStats, TableStatistics, Tags, Table as _NativeTable } from "./native";
4
+ import { AddColumnsResult, AddColumnsSql, AddResult, AlterColumnsResult, DeleteResult, DropColumnsResult, IndexConfig, IndexStatistics, OptimizeStats, TableStatistics, Tags, UpdateResult, Table as _NativeTable } from "./native";
5
5
  import { FullTextQuery, Query, VectorQuery } from "./query";
6
6
  import { IntoSql } from "./util";
7
7
  export { IndexConfig } from "./native";
@@ -89,12 +89,16 @@ export declare abstract class Table {
89
89
  /**
90
90
  * Insert records into this Table.
91
91
  * @param {Data} data Records to be inserted into the Table
92
+ * @returns {Promise<AddResult>} A promise that resolves to an object
93
+ * containing the new version number of the table
92
94
  */
93
- abstract add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
95
+ abstract add(data: Data, options?: Partial<AddDataOptions>): Promise<AddResult>;
94
96
  /**
95
97
  * Update existing records in the Table
96
98
  * @param opts.values The values to update. The keys are the column names and the values
97
99
  * are the values to set.
100
+ * @returns {Promise<UpdateResult>} A promise that resolves to an object containing
101
+ * the number of rows updated and the new version number
98
102
  * @example
99
103
  * ```ts
100
104
  * table.update({where:"x = 2", values:{"vector": [10, 10]}})
@@ -102,11 +106,13 @@ export declare abstract class Table {
102
106
  */
103
107
  abstract update(opts: {
104
108
  values: Map<string, IntoSql> | Record<string, IntoSql>;
105
- } & Partial<UpdateOptions>): Promise<void>;
109
+ } & Partial<UpdateOptions>): Promise<UpdateResult>;
106
110
  /**
107
111
  * Update existing records in the Table
108
112
  * @param opts.valuesSql The values to update. The keys are the column names and the values
109
113
  * are the values to set. The values are SQL expressions.
114
+ * @returns {Promise<UpdateResult>} A promise that resolves to an object containing
115
+ * the number of rows updated and the new version number
110
116
  * @example
111
117
  * ```ts
112
118
  * table.update({where:"x = 2", valuesSql:{"x": "x + 1"}})
@@ -114,7 +120,7 @@ export declare abstract class Table {
114
120
  */
115
121
  abstract update(opts: {
116
122
  valuesSql: Map<string, string> | Record<string, string>;
117
- } & Partial<UpdateOptions>): Promise<void>;
123
+ } & Partial<UpdateOptions>): Promise<UpdateResult>;
118
124
  /**
119
125
  * Update existing records in the Table
120
126
  *
@@ -132,6 +138,8 @@ export declare abstract class Table {
132
138
  * repeatedly calilng this method.
133
139
  * @param {Map<string, string> | Record<string, string>} updates - the
134
140
  * columns to update
141
+ * @returns {Promise<UpdateResult>} A promise that resolves to an object
142
+ * containing the number of rows updated and the new version number
135
143
  *
136
144
  * Keys in the map should specify the name of the column to update.
137
145
  * Values in the map provide the new value of the column. These can
@@ -140,11 +148,15 @@ export declare abstract class Table {
140
148
  * @param {Partial<UpdateOptions>} options - additional options to control
141
149
  * the update behavior
142
150
  */
143
- abstract update(updates: Map<string, string> | Record<string, string>, options?: Partial<UpdateOptions>): Promise<void>;
151
+ abstract update(updates: Map<string, string> | Record<string, string>, options?: Partial<UpdateOptions>): Promise<UpdateResult>;
144
152
  /** Count the total number of rows in the dataset. */
145
153
  abstract countRows(filter?: string): Promise<number>;
146
- /** Delete the rows that satisfy the predicate. */
147
- abstract delete(predicate: string): Promise<void>;
154
+ /**
155
+ * Delete the rows that satisfy the predicate.
156
+ * @returns {Promise<DeleteResult>} A promise that resolves to an object
157
+ * containing the new version number of the table
158
+ */
159
+ abstract delete(predicate: string): Promise<DeleteResult>;
148
160
  /**
149
161
  * Create an index to speed up queries.
150
162
  *
@@ -283,14 +295,18 @@ export declare abstract class Table {
283
295
  * the SQL expression to use to calculate the value of the new column. These
284
296
  * expressions will be evaluated for each row in the table, and can
285
297
  * reference existing columns in the table.
298
+ * @returns {Promise<AddColumnsResult>} A promise that resolves to an object
299
+ * containing the new version number of the table after adding the columns.
286
300
  */
287
- abstract addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
301
+ abstract addColumns(newColumnTransforms: AddColumnsSql[]): Promise<AddColumnsResult>;
288
302
  /**
289
303
  * Alter the name or nullability of columns.
290
304
  * @param {ColumnAlteration[]} columnAlterations One or more alterations to
291
305
  * apply to columns.
306
+ * @returns {Promise<AlterColumnsResult>} A promise that resolves to an object
307
+ * containing the new version number of the table after altering the columns.
292
308
  */
293
- abstract alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
309
+ abstract alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
294
310
  /**
295
311
  * Drop one or more columns from the dataset
296
312
  *
@@ -301,8 +317,10 @@ export declare abstract class Table {
301
317
  * @param {string[]} columnNames The names of the columns to drop. These can
302
318
  * be nested column references (e.g. "a.b.c") or top-level column names
303
319
  * (e.g. "a").
320
+ * @returns {Promise<DropColumnsResult>} A promise that resolves to an object
321
+ * containing the new version number of the table after dropping the columns.
304
322
  */
305
- abstract dropColumns(columnNames: string[]): Promise<void>;
323
+ abstract dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
306
324
  /** Retrieve the version of the table */
307
325
  abstract version(): Promise<number>;
308
326
  /**
@@ -432,14 +450,14 @@ export declare class LocalTable extends Table {
432
450
  private getEmbeddingFunctions;
433
451
  /** Get the schema of the table. */
434
452
  schema(): Promise<Schema>;
435
- add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
453
+ add(data: Data, options?: Partial<AddDataOptions>): Promise<AddResult>;
436
454
  update(optsOrUpdates: (Map<string, string> | Record<string, string>) | ({
437
455
  values: Map<string, IntoSql> | Record<string, IntoSql>;
438
456
  } & Partial<UpdateOptions>) | ({
439
457
  valuesSql: Map<string, string> | Record<string, string>;
440
- } & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<void>;
458
+ } & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<UpdateResult>;
441
459
  countRows(filter?: string): Promise<number>;
442
- delete(predicate: string): Promise<void>;
460
+ delete(predicate: string): Promise<DeleteResult>;
443
461
  createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
444
462
  dropIndex(name: string): Promise<void>;
445
463
  prewarmIndex(name: string): Promise<void>;
@@ -447,9 +465,9 @@ export declare class LocalTable extends Table {
447
465
  query(): Query;
448
466
  search(query: string | IntoVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
449
467
  vectorSearch(vector: IntoVector): VectorQuery;
450
- addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
451
- alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
452
- dropColumns(columnNames: string[]): Promise<void>;
468
+ addColumns(newColumnTransforms: AddColumnsSql[]): Promise<AddColumnsResult>;
469
+ alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
470
+ dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
453
471
  version(): Promise<number>;
454
472
  checkout(version: number | string): Promise<void>;
455
473
  checkoutLatest(): Promise<void>;
package/dist/table.js CHANGED
@@ -66,7 +66,7 @@ class LocalTable extends Table {
66
66
  const mode = options?.mode ?? "append";
67
67
  const schema = await this.schema();
68
68
  const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
69
- await this.inner.add(buffer, mode);
69
+ return await this.inner.add(buffer, mode);
70
70
  }
71
71
  async update(optsOrUpdates, options) {
72
72
  const isValues = "values" in optsOrUpdates && typeof optsOrUpdates.values !== "string";
@@ -111,13 +111,13 @@ class LocalTable extends Table {
111
111
  columns = Object.entries(optsOrUpdates);
112
112
  predicate = options?.where;
113
113
  }
114
- await this.inner.update(predicate, columns);
114
+ return await this.inner.update(predicate, columns);
115
115
  }
116
116
  async countRows(filter) {
117
117
  return await this.inner.countRows(filter);
118
118
  }
119
119
  async delete(predicate) {
120
- await this.inner.delete(predicate);
120
+ return await this.inner.delete(predicate);
121
121
  }
122
122
  async createIndex(column, options) {
123
123
  // Bit of a hack to get around the fact that TS has no package-scope.
@@ -175,7 +175,7 @@ class LocalTable extends Table {
175
175
  }
176
176
  // TODO: Support BatchUDF
177
177
  async addColumns(newColumnTransforms) {
178
- await this.inner.addColumns(newColumnTransforms);
178
+ return await this.inner.addColumns(newColumnTransforms);
179
179
  }
180
180
  async alterColumns(columnAlterations) {
181
181
  const processedAlterations = columnAlterations.map((alteration) => {
@@ -199,10 +199,10 @@ class LocalTable extends Table {
199
199
  };
200
200
  }
201
201
  });
202
- await this.inner.alterColumns(processedAlterations);
202
+ return await this.inner.alterColumns(processedAlterations);
203
203
  }
204
204
  async dropColumns(columnNames) {
205
- await this.inner.dropColumns(columnNames);
205
+ return await this.inner.dropColumns(columnNames);
206
206
  }
207
207
  async version() {
208
208
  return await this.inner.version();
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.19.1-beta.1",
14
+ "version": "0.19.1-beta.2",
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.19.1-beta.1",
104
- "@lancedb/lancedb-darwin-arm64": "0.19.1-beta.1",
105
- "@lancedb/lancedb-linux-x64-gnu": "0.19.1-beta.1",
106
- "@lancedb/lancedb-linux-arm64-gnu": "0.19.1-beta.1",
107
- "@lancedb/lancedb-linux-x64-musl": "0.19.1-beta.1",
108
- "@lancedb/lancedb-linux-arm64-musl": "0.19.1-beta.1",
109
- "@lancedb/lancedb-win32-x64-msvc": "0.19.1-beta.1",
110
- "@lancedb/lancedb-win32-arm64-msvc": "0.19.1-beta.1"
103
+ "@lancedb/lancedb-darwin-x64": "0.19.1-beta.2",
104
+ "@lancedb/lancedb-darwin-arm64": "0.19.1-beta.2",
105
+ "@lancedb/lancedb-linux-x64-gnu": "0.19.1-beta.2",
106
+ "@lancedb/lancedb-linux-arm64-gnu": "0.19.1-beta.2",
107
+ "@lancedb/lancedb-linux-x64-musl": "0.19.1-beta.2",
108
+ "@lancedb/lancedb-linux-arm64-musl": "0.19.1-beta.2",
109
+ "@lancedb/lancedb-win32-x64-msvc": "0.19.1-beta.2",
110
+ "@lancedb/lancedb-win32-arm64-msvc": "0.19.1-beta.2"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "apache-arrow": ">=15.0.0 <=18.1.0"