@lancedb/lancedb 0.19.1-beta.0 → 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, 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
@@ -191,11 +191,70 @@ export interface IndexStatistics {
191
191
  */
192
192
  loss?: number
193
193
  }
194
+ export interface TableStatistics {
195
+ /** The total number of bytes in the table */
196
+ totalBytes: number
197
+ /** The number of rows in the table */
198
+ numRows: number
199
+ /** The number of indices in the table */
200
+ numIndices: number
201
+ /** Statistics on table fragments */
202
+ fragmentStats: FragmentStatistics
203
+ }
204
+ export interface FragmentStatistics {
205
+ /** The number of fragments in the table */
206
+ numFragments: number
207
+ /** The number of uncompacted fragments in the table */
208
+ numSmallFragments: number
209
+ /** Statistics on the number of rows in the table fragments */
210
+ lengths: FragmentSummaryStats
211
+ }
212
+ export interface FragmentSummaryStats {
213
+ /** The number of rows in the fragment with the fewest rows */
214
+ min: number
215
+ /** The number of rows in the fragment with the most rows */
216
+ max: number
217
+ /** The mean number of rows in the fragments */
218
+ mean: number
219
+ /** The 25th percentile of number of rows in the fragments */
220
+ p25: number
221
+ /** The 50th percentile of number of rows in the fragments */
222
+ p50: number
223
+ /** The 75th percentile of number of rows in the fragments */
224
+ p75: number
225
+ /** The 99th percentile of number of rows in the fragments */
226
+ p99: number
227
+ }
194
228
  export interface Version {
195
229
  version: number
196
230
  timestamp: number
197
231
  metadata: Record<string, string>
198
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
+ }
199
258
  export interface ConnectionOptions {
200
259
  /**
201
260
  * (For LanceDB OSS only): The interval, in seconds, at which to check for
@@ -279,7 +338,7 @@ export class NativeMergeInsertBuilder {
279
338
  whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
280
339
  whenNotMatchedInsertAll(): NativeMergeInsertBuilder
281
340
  whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
282
- execute(buf: Buffer): Promise<void>
341
+ execute(buf: Buffer): Promise<MergeResult>
283
342
  }
284
343
  export class Query {
285
344
  onlyIf(predicate: string): void
@@ -346,19 +405,20 @@ export class Table {
346
405
  close(): void
347
406
  /** Return Schema as empty Arrow IPC file. */
348
407
  schema(): Promise<Buffer>
349
- add(buf: Buffer, mode: string): Promise<void>
408
+ add(buf: Buffer, mode: string): Promise<AddResult>
350
409
  countRows(filter?: string | undefined | null): Promise<number>
351
- delete(predicate: string): Promise<void>
410
+ delete(predicate: string): Promise<DeleteResult>
352
411
  createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null, waitTimeoutS?: number | undefined | null): Promise<void>
353
412
  dropIndex(indexName: string): Promise<void>
354
413
  prewarmIndex(indexName: string): Promise<void>
355
414
  waitForIndex(indexNames: Array<string>, timeoutS: number): Promise<void>
356
- update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<bigint>
415
+ stats(): Promise<TableStatistics>
416
+ update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<UpdateResult>
357
417
  query(): Query
358
418
  vectorSearch(vector: Float32Array): VectorQuery
359
- addColumns(transforms: Array<AddColumnsSql>): Promise<void>
360
- alterColumns(alterations: Array<ColumnAlteration>): Promise<void>
361
- 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>
362
422
  version(): Promise<number>
363
423
  checkout(version: number): Promise<void>
364
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, 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
  /**
@@ -415,6 +433,12 @@ export declare abstract class Table {
415
433
  * Use {@link Table.listIndices} to find the names of the indices.
416
434
  */
417
435
  abstract indexStats(name: string): Promise<IndexStatistics | undefined>;
436
+ /** Returns table and fragment statistics
437
+ *
438
+ * @returns {TableStatistics} The table and fragment statistics
439
+ *
440
+ */
441
+ abstract stats(): Promise<TableStatistics>;
418
442
  }
419
443
  export declare class LocalTable extends Table {
420
444
  private readonly inner;
@@ -426,14 +450,14 @@ export declare class LocalTable extends Table {
426
450
  private getEmbeddingFunctions;
427
451
  /** Get the schema of the table. */
428
452
  schema(): Promise<Schema>;
429
- add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
453
+ add(data: Data, options?: Partial<AddDataOptions>): Promise<AddResult>;
430
454
  update(optsOrUpdates: (Map<string, string> | Record<string, string>) | ({
431
455
  values: Map<string, IntoSql> | Record<string, IntoSql>;
432
456
  } & Partial<UpdateOptions>) | ({
433
457
  valuesSql: Map<string, string> | Record<string, string>;
434
- } & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<void>;
458
+ } & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<UpdateResult>;
435
459
  countRows(filter?: string): Promise<number>;
436
- delete(predicate: string): Promise<void>;
460
+ delete(predicate: string): Promise<DeleteResult>;
437
461
  createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
438
462
  dropIndex(name: string): Promise<void>;
439
463
  prewarmIndex(name: string): Promise<void>;
@@ -441,9 +465,9 @@ export declare class LocalTable extends Table {
441
465
  query(): Query;
442
466
  search(query: string | IntoVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
443
467
  vectorSearch(vector: IntoVector): VectorQuery;
444
- addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
445
- alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
446
- dropColumns(columnNames: string[]): Promise<void>;
468
+ addColumns(newColumnTransforms: AddColumnsSql[]): Promise<AddColumnsResult>;
469
+ alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
470
+ dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
447
471
  version(): Promise<number>;
448
472
  checkout(version: number | string): Promise<void>;
449
473
  checkoutLatest(): Promise<void>;
@@ -454,6 +478,7 @@ export declare class LocalTable extends Table {
454
478
  listIndices(): Promise<IndexConfig[]>;
455
479
  toArrow(): Promise<ArrowTable>;
456
480
  indexStats(name: string): Promise<IndexStatistics | undefined>;
481
+ stats(): Promise<TableStatistics>;
457
482
  mergeInsert(on: string | string[]): MergeInsertBuilder;
458
483
  /**
459
484
  * Check if the table uses the new manifest path scheme.
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();
@@ -251,6 +251,9 @@ class LocalTable extends Table {
251
251
  }
252
252
  return stats;
253
253
  }
254
+ async stats() {
255
+ return await this.inner.stats();
256
+ }
254
257
  mergeInsert(on) {
255
258
  on = Array.isArray(on) ? on : [on];
256
259
  return new merge_1.MergeInsertBuilder(this.inner.mergeInsert(on), this.schema());
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.19.1-beta.0",
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.0",
104
- "@lancedb/lancedb-darwin-arm64": "0.19.1-beta.0",
105
- "@lancedb/lancedb-linux-x64-gnu": "0.19.1-beta.0",
106
- "@lancedb/lancedb-linux-arm64-gnu": "0.19.1-beta.0",
107
- "@lancedb/lancedb-linux-x64-musl": "0.19.1-beta.0",
108
- "@lancedb/lancedb-linux-arm64-musl": "0.19.1-beta.0",
109
- "@lancedb/lancedb-win32-x64-msvc": "0.19.1-beta.0",
110
- "@lancedb/lancedb-win32-arm64-msvc": "0.19.1-beta.0"
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"