@lancedb/lancedb 0.40.0 → 0.41.0-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/schema.js CHANGED
@@ -43,10 +43,18 @@ class SchemaInferrer {
43
43
  else if (this.providedSchema === undefined) {
44
44
  this.updateInferredField(path, value, row, current);
45
45
  }
46
+ else if (current instanceof DeferredTypeEvidence) {
47
+ if (value != null) {
48
+ this.addSchemaField(this.providedSchema, path, value, row);
49
+ }
50
+ }
51
+ else if (current instanceof FieldTree || apache_arrow_1.DataType.isStruct(current)) {
52
+ assertStructValue(path, value, row);
53
+ }
46
54
  }
47
55
  addField(path, value, row) {
48
56
  if (this.providedSchema !== undefined) {
49
- this.addSchemaField(this.providedSchema, path, row);
57
+ this.addSchemaField(this.providedSchema, path, value, row);
50
58
  return;
51
59
  }
52
60
  const evidence = this.inferType(value, path) ?? DeferredTypeEvidence.from(value, row);
@@ -58,12 +66,18 @@ class SchemaInferrer {
58
66
  throw branchConflictError(conflict, row, "Struct");
59
67
  }
60
68
  }
61
- addSchemaField(schema, path, row) {
69
+ addSchemaField(schema, path, value, row) {
62
70
  const field = fieldAtPath(schema, path);
63
71
  if (field === undefined) {
64
72
  throw new Error(`Found field not in schema: ${path.join(".")} at row ${row}`);
65
73
  }
66
- const conflict = this.fields.set(path, field.type);
74
+ if (apache_arrow_1.DataType.isStruct(field.type)) {
75
+ assertStructValue(path, value, row);
76
+ }
77
+ // Nulls are kept as deferred evidence so that a struct field seen first as
78
+ // null can be replaced by a record in a later row, just as a record seen
79
+ // first already ignores later nulls.
80
+ const conflict = this.fields.set(path, DeferredTypeEvidence.from(value, row) ?? field.type, (existing) => existing instanceof DeferredTypeEvidence && existing.isOnlyNulls());
67
81
  if (conflict !== undefined) {
68
82
  throw branchConflictError(conflict, row, "Struct");
69
83
  }
@@ -332,6 +346,20 @@ function assertSupportedValue(value, field, row) {
332
346
  throw new Error(`Unsupported object value for field ${field} at row ${row}.`);
333
347
  }
334
348
  }
349
+ /**
350
+ * Rejects primitives, arrays, and typed arrays given for a struct field, which
351
+ * would otherwise be written as a struct with every child null.
352
+ */
353
+ function assertStructValue(path, value, row) {
354
+ if (value == null ||
355
+ (typeof value === "object" &&
356
+ !Array.isArray(value) &&
357
+ !ArrayBuffer.isView(value))) {
358
+ return;
359
+ }
360
+ const kind = typeof value === "object" ? value.constructor.name : typeof value;
361
+ throw new Error(`Expected a struct value for field ${path.join(".")} at row ${row}, got ${kind}.`);
362
+ }
335
363
  function fieldAtPath(schema, path) {
336
364
  let fields = schema.fields;
337
365
  let field;
package/dist/table.d.ts CHANGED
@@ -157,9 +157,8 @@ export interface LsmWriteSpec {
157
157
  /** Bucket variant: the number of buckets, in `[1, 1024]`. */
158
158
  numBuckets?: number;
159
159
  /**
160
- * Indexes the MemWAL keeps up to date. Omit to maintain every supported
161
- * index, resolved on install — a snapshot, so indexes created later are not
162
- * maintained. Pass `[]` for none.
160
+ * Indexes the MemWAL keeps up to date. Omit for every index the table has,
161
+ * including ones created later. Pass `[]` for none.
163
162
  */
164
163
  maintainedIndexes?: string[];
165
164
  /** Default `ShardWriter` configuration recorded in the MemWAL index. */
@@ -556,7 +555,7 @@ export declare abstract class Table {
556
555
  * it: rejects tables that carry no view definition.
557
556
  * @ignore
558
557
  */
559
- abstract refreshMaterializedView(full?: boolean, sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
558
+ abstract refreshMaterializedView(sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
560
559
  /** @ignore */
561
560
  abstract materializedViewDefinition(): Promise<string>;
562
561
  /**
@@ -628,8 +627,8 @@ export declare abstract class Table {
628
627
  * ({@link Table#setUnenforcedPrimaryKey}); bucket sharding additionally
629
628
  * requires it to be the single column being bucketed.
630
629
  *
631
- * Omitting `maintainedIndexes` maintains every index on the table, resolved
632
- * here, failing if one cannot be maintained — name them to install anyway.
630
+ * Omitting `maintainedIndexes` maintains every index the table has,
631
+ * including ones created later, and skips a kind the MemWAL cannot maintain.
633
632
  * Naming them pins an exact set, and a still-building index is rejected
634
633
  * rather than quietly omitted.
635
634
  * @param {LsmWriteSpec} spec The sharding spec to install.
@@ -659,10 +658,9 @@ export declare abstract class Table {
659
658
  *
660
659
  * Resolves to `undefined` when the MemWAL LSM write path is not enabled (no
661
660
  * spec has been set, or it was removed with {@link Table#unsetLsmWriteSpec}).
662
- * The returned spec mirrors what was passed to
663
- * {@link Table#setLsmWriteSpec}, except that `maintainedIndexes` always
664
- * reports the concrete list resolved when the spec was set — `undefined`
665
- * never round-trips.
661
+ * The spec is the one installed, including its maintained-index selection:
662
+ * an absent `maintainedIndexes` for every index the table has, an empty
663
+ * array for none.
666
664
  * @returns {Promise<LsmWriteSpec | undefined>}
667
665
  */
668
666
  abstract getLsmWriteSpec(): Promise<LsmWriteSpec | undefined>;
@@ -929,7 +927,7 @@ export declare class LocalTable extends Table {
929
927
  refreshColumn(column: string): Promise<RefreshColumnResult>;
930
928
  refreshColumnAsync(column: string): Promise<Job>;
931
929
  functionErrors(options?: FunctionErrorsOptions): Promise<FunctionErrors>;
932
- refreshMaterializedView(full?: boolean, sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
930
+ refreshMaterializedView(sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
933
931
  materializedViewDefinition(): Promise<string>;
934
932
  alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
935
933
  updateFieldMetadata(updates: FieldMetadataUpdate[]): Promise<UpdateFieldMetadataResult>;
package/dist/table.js CHANGED
@@ -280,8 +280,8 @@ class LocalTable extends Table {
280
280
  (0, materialized_view_1.validateNonNegativeInteger)(options?.limit, "limit");
281
281
  return await this.inner.functionErrors(options);
282
282
  }
283
- async refreshMaterializedView(full, sourceVersion) {
284
- return await this.inner.refreshMaterializedView(full, sourceVersion);
283
+ async refreshMaterializedView(sourceVersion) {
284
+ return await this.inner.refreshMaterializedView(sourceVersion);
285
285
  }
286
286
  async materializedViewDefinition() {
287
287
  return await this.inner.materializedViewDefinition();
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.40.0",
14
+ "version": "0.41.0-beta.2",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -49,10 +49,14 @@
49
49
  "@types/jest": "^29.1.2",
50
50
  "@types/node": "22.7.4",
51
51
  "@types/tmp": "^0.2.6",
52
+ "apache-arrow": "21.2.0",
52
53
  "apache-arrow-15": "npm:apache-arrow@15.0.0",
53
54
  "apache-arrow-16": "npm:apache-arrow@16.0.0",
54
55
  "apache-arrow-17": "npm:apache-arrow@17.0.0",
55
56
  "apache-arrow-18": "npm:apache-arrow@18.0.0",
57
+ "apache-arrow-19": "npm:apache-arrow@19.0.1",
58
+ "apache-arrow-20": "npm:apache-arrow@20.0.0",
59
+ "apache-arrow-21": "npm:apache-arrow@21.2.0",
56
60
  "eslint": "^8.57.0",
57
61
  "jest": "^29.7.0",
58
62
  "shx": "^0.3.4",
@@ -106,17 +110,17 @@
106
110
  "optionalDependencies": {
107
111
  "@huggingface/transformers": "3.0.2",
108
112
  "openai": "4.29.2",
109
- "@lancedb/lancedb-darwin-arm64": "0.40.0",
110
- "@lancedb/lancedb-linux-x64-gnu": "0.40.0",
111
- "@lancedb/lancedb-linux-arm64-gnu": "0.40.0",
112
- "@lancedb/lancedb-linux-x64-musl": "0.40.0",
113
- "@lancedb/lancedb-linux-arm64-musl": "0.40.0",
114
- "@lancedb/lancedb-win32-x64-msvc": "0.40.0",
115
- "@lancedb/lancedb-win32-arm64-msvc": "0.40.0"
113
+ "@lancedb/lancedb-darwin-arm64": "0.41.0-beta.2",
114
+ "@lancedb/lancedb-linux-x64-gnu": "0.41.0-beta.2",
115
+ "@lancedb/lancedb-linux-arm64-gnu": "0.41.0-beta.2",
116
+ "@lancedb/lancedb-linux-x64-musl": "0.41.0-beta.2",
117
+ "@lancedb/lancedb-linux-arm64-musl": "0.41.0-beta.2",
118
+ "@lancedb/lancedb-win32-x64-msvc": "0.41.0-beta.2",
119
+ "@lancedb/lancedb-win32-arm64-msvc": "0.41.0-beta.2"
116
120
  },
117
121
  "peerDependencies": {
118
122
  "@types/node": ">=22",
119
- "apache-arrow": ">=15.0.0 <=18.1.0"
123
+ "apache-arrow": ">=15.0.0 <22.0.0"
120
124
  },
121
125
  "peerDependenciesMeta": {
122
126
  "@types/node": {