@lancedb/lancedb 0.38.0-beta.3 → 0.38.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.
package/dist/schema.js ADDED
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright The LanceDB Authors
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.inferSchema = inferSchema;
6
+ const apache_arrow_1 = require("apache-arrow");
7
+ const arrow_type_1 = require("./arrow_type");
8
+ const sanitize_1 = require("./sanitize");
9
+ /**
10
+ * Infer the Arrow schema represented by a set of records.
11
+ *
12
+ * This is the intentionally small interface to schema inference. The stateful
13
+ * details of combining partial type evidence are encapsulated below so callers
14
+ * only need to provide records, an optional schema, and inference options.
15
+ */
16
+ function inferSchema(data, schema, options) {
17
+ return new SchemaInferrer(schema, options).infer(data);
18
+ }
19
+ class SchemaInferrer {
20
+ providedSchema;
21
+ options;
22
+ fields = new FieldTree();
23
+ constructor(providedSchema, options) {
24
+ this.providedSchema = providedSchema;
25
+ this.options = options;
26
+ }
27
+ infer(data) {
28
+ for (const [row, record] of data.entries()) {
29
+ for (const [path, value] of recordPathsAndValues(record)) {
30
+ this.observe(path, value, row);
31
+ }
32
+ }
33
+ return this.providedSchema === undefined
34
+ ? new apache_arrow_1.Schema(fieldsFromTree(this.fields))
35
+ : new apache_arrow_1.Schema(matchingFields(this.providedSchema.fields, this.fields));
36
+ }
37
+ observe(path, value, row) {
38
+ const current = this.fields.get(path);
39
+ if (current === undefined) {
40
+ this.addField(path, value, row);
41
+ }
42
+ else if (this.providedSchema === undefined) {
43
+ this.updateInferredField(path, value, row, current);
44
+ }
45
+ }
46
+ addField(path, value, row) {
47
+ if (this.providedSchema !== undefined) {
48
+ this.addSchemaField(this.providedSchema, path, row);
49
+ return;
50
+ }
51
+ const evidence = this.inferType(value, path) ?? DeferredTypeEvidence.from(value, row);
52
+ if (evidence === undefined) {
53
+ throw typeInferenceError(path, row);
54
+ }
55
+ const conflict = this.fields.set(path, evidence, (existing) => existing instanceof DeferredTypeEvidence && existing.isOnlyNulls());
56
+ if (conflict !== undefined) {
57
+ throw branchConflictError(conflict, row, "Struct");
58
+ }
59
+ }
60
+ addSchemaField(schema, path, row) {
61
+ const field = fieldAtPath(schema, path);
62
+ if (field === undefined) {
63
+ throw new Error(`Found field not in schema: ${path.join(".")} at row ${row}`);
64
+ }
65
+ const conflict = this.fields.set(path, field.type);
66
+ if (conflict !== undefined) {
67
+ throw branchConflictError(conflict, row, "Struct");
68
+ }
69
+ }
70
+ updateInferredField(path, value, row, current) {
71
+ const newType = this.inferType(value, path);
72
+ const deferred = DeferredTypeEvidence.from(value, row);
73
+ if (current instanceof FieldTree) {
74
+ if (deferred?.isOnlyNulls()) {
75
+ return;
76
+ }
77
+ throw schemaInferenceError(path, row, "Struct", describeEvidence(newType ?? deferred));
78
+ }
79
+ if (current instanceof DeferredTypeEvidence) {
80
+ this.resolveDeferredField(path, row, current, newType, deferred);
81
+ return;
82
+ }
83
+ if (newType !== undefined) {
84
+ if (!inferredTypesEqual(current, newType)) {
85
+ throw schemaInferenceError(path, row, describeEvidence(current), describeEvidence(newType));
86
+ }
87
+ return;
88
+ }
89
+ if (deferred === undefined || !deferred.matches(current)) {
90
+ throw schemaInferenceError(path, row, describeEvidence(current), describeEvidence(deferred));
91
+ }
92
+ }
93
+ resolveDeferredField(path, row, current, newType, deferred) {
94
+ if (newType !== undefined) {
95
+ if (!current.matches(newType)) {
96
+ throw schemaInferenceError(path, row, current.describe(), describeEvidence(newType));
97
+ }
98
+ this.fields.set(path, newType);
99
+ return;
100
+ }
101
+ if (deferred !== undefined) {
102
+ this.fields.set(path, current.merge(deferred));
103
+ return;
104
+ }
105
+ throw schemaInferenceError(path, row, current.describe(), describeEvidence(newType));
106
+ }
107
+ inferType(value, path) {
108
+ if (typeof value === "bigint") {
109
+ return new apache_arrow_1.Int64();
110
+ }
111
+ if (typeof value === "number") {
112
+ return new apache_arrow_1.Float64();
113
+ }
114
+ if (typeof value === "string") {
115
+ return this.options.dictionaryEncodeStrings
116
+ ? new apache_arrow_1.Dictionary(new apache_arrow_1.Utf8(), new apache_arrow_1.Int32())
117
+ : new apache_arrow_1.Utf8();
118
+ }
119
+ if (typeof value === "boolean") {
120
+ return new apache_arrow_1.Bool();
121
+ }
122
+ if (value instanceof Buffer) {
123
+ return new apache_arrow_1.Binary();
124
+ }
125
+ if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
126
+ const typedArray = (0, arrow_type_1.typedArrayToArrowType)(value);
127
+ return typedArray === undefined
128
+ ? undefined
129
+ : new apache_arrow_1.FixedSizeList(typedArray.length, new apache_arrow_1.Field("item", typedArray.elementType, true));
130
+ }
131
+ if (!Array.isArray(value) || value.length === 0) {
132
+ return undefined;
133
+ }
134
+ const configuredVector = path.length === 1 ? this.options.vectorColumns[path[0]] : undefined;
135
+ if (configuredVector !== undefined) {
136
+ return new apache_arrow_1.FixedSizeList(value.length, new apache_arrow_1.Field("item", (0, sanitize_1.sanitizeType)(configuredVector.type), true));
137
+ }
138
+ const itemType = this.inferArrayItemType(value, path);
139
+ if (itemType === undefined) {
140
+ return undefined;
141
+ }
142
+ return nameSuggestsVectorColumn(path[path.length - 1])
143
+ ? new apache_arrow_1.FixedSizeList(value.length, new apache_arrow_1.Field("item", new apache_arrow_1.Float32(), true))
144
+ : new apache_arrow_1.List(new apache_arrow_1.Field("item", itemType, true));
145
+ }
146
+ inferArrayItemType(values, path) {
147
+ let itemType;
148
+ const deferredItems = [];
149
+ for (const value of values) {
150
+ const candidate = this.inferType(value, path);
151
+ if (candidate === undefined) {
152
+ if (!isDeferredValue(value)) {
153
+ return undefined;
154
+ }
155
+ deferredItems.push(value);
156
+ }
157
+ else if (itemType === undefined) {
158
+ itemType = candidate;
159
+ }
160
+ else if (!inferredTypesEqual(itemType, candidate)) {
161
+ return undefined;
162
+ }
163
+ }
164
+ if (itemType === undefined) {
165
+ return undefined;
166
+ }
167
+ return deferredItems.every((value) => deferredValueMatchesType(value, itemType))
168
+ ? itemType
169
+ : undefined;
170
+ }
171
+ }
172
+ /** Nulls and empty/all-null lists that do not determine a type by themselves. */
173
+ class DeferredTypeEvidence {
174
+ values;
175
+ constructor(values) {
176
+ this.values = values;
177
+ }
178
+ static from(value, row) {
179
+ return isDeferredValue(value)
180
+ ? new DeferredTypeEvidence([{ value, row }])
181
+ : undefined;
182
+ }
183
+ isOnlyNulls() {
184
+ return this.values.every(({ value }) => value == null);
185
+ }
186
+ matches(type) {
187
+ return this.values.every(({ value }) => deferredValueMatchesType(value, type));
188
+ }
189
+ merge(other) {
190
+ return new DeferredTypeEvidence([...this.values, ...other.values]);
191
+ }
192
+ describe() {
193
+ const list = this.values.find(({ value }) => Array.isArray(value));
194
+ return list === undefined
195
+ ? "null"
196
+ : `List[${list.value.length}]`;
197
+ }
198
+ firstRow() {
199
+ return this.values[0].row;
200
+ }
201
+ }
202
+ /** Nested field state, kept separate from Arrow's eventual Struct types. */
203
+ class FieldTree {
204
+ children = new Map();
205
+ get(path) {
206
+ let current = this;
207
+ for (const part of path) {
208
+ if (!(current instanceof FieldTree)) {
209
+ return undefined;
210
+ }
211
+ const child = current.children.get(part);
212
+ if (child === undefined) {
213
+ return undefined;
214
+ }
215
+ current = child;
216
+ }
217
+ return current;
218
+ }
219
+ set(path, value, canReplaceLeaf = () => false) {
220
+ let branch = this;
221
+ for (const [index, part] of path.slice(0, -1).entries()) {
222
+ const child = branch.children.get(part);
223
+ if (child === undefined || (isLeaf(child) && canReplaceLeaf(child))) {
224
+ const nextBranch = new FieldTree();
225
+ branch.children.set(part, nextBranch);
226
+ branch = nextBranch;
227
+ }
228
+ else if (child instanceof FieldTree) {
229
+ branch = child;
230
+ }
231
+ else {
232
+ return { path: path.slice(0, index + 1), value: child };
233
+ }
234
+ }
235
+ const name = path[path.length - 1];
236
+ const current = branch.children.get(name);
237
+ if (current instanceof FieldTree) {
238
+ return { path, value: current };
239
+ }
240
+ branch.children.set(name, value);
241
+ return undefined;
242
+ }
243
+ entries() {
244
+ return this.children.entries();
245
+ }
246
+ has(name) {
247
+ return this.children.has(name);
248
+ }
249
+ }
250
+ function isLeaf(value) {
251
+ return !(value instanceof FieldTree);
252
+ }
253
+ function fieldsFromTree(tree, path = []) {
254
+ const fields = [];
255
+ for (const [name, value] of tree.entries()) {
256
+ if (value instanceof FieldTree) {
257
+ fields.push(new apache_arrow_1.Field(name, new apache_arrow_1.Struct(fieldsFromTree(value, [...path, name])), true));
258
+ }
259
+ else if (value instanceof DeferredTypeEvidence) {
260
+ throw typeInferenceError([...path, name], value.firstRow());
261
+ }
262
+ else {
263
+ fields.push(new apache_arrow_1.Field(name, value, true));
264
+ }
265
+ }
266
+ return fields;
267
+ }
268
+ function matchingFields(fields, tree) {
269
+ const matches = [];
270
+ for (const field of fields) {
271
+ if (!tree.has(field.name)) {
272
+ continue;
273
+ }
274
+ const value = tree.get([field.name]);
275
+ if (value instanceof FieldTree) {
276
+ const struct = field.type;
277
+ matches.push(new apache_arrow_1.Field(field.name, new apache_arrow_1.Struct(matchingFields(struct.children, value)), field.nullable, field.metadata));
278
+ }
279
+ else {
280
+ matches.push(field);
281
+ }
282
+ }
283
+ return matches;
284
+ }
285
+ function* recordPathsAndValues(record, path = []) {
286
+ for (const [name, value] of Object.entries(record)) {
287
+ if (isRecord(value)) {
288
+ yield* recordPathsAndValues(value, [...path, name]);
289
+ }
290
+ else if (value !== undefined) {
291
+ yield [[...path, name], value];
292
+ }
293
+ }
294
+ }
295
+ function isRecord(value) {
296
+ return (typeof value === "object" &&
297
+ value !== null &&
298
+ !Array.isArray(value) &&
299
+ !(value instanceof RegExp) &&
300
+ !(value instanceof Date) &&
301
+ !(value instanceof Set) &&
302
+ !(value instanceof Map) &&
303
+ !(value instanceof Buffer) &&
304
+ !ArrayBuffer.isView(value));
305
+ }
306
+ function fieldAtPath(schema, path) {
307
+ let fields = schema.fields;
308
+ let field;
309
+ for (const [index, name] of path.entries()) {
310
+ field = fields.find((candidate) => candidate.name === name);
311
+ if (field === undefined || index === path.length - 1) {
312
+ return field;
313
+ }
314
+ if (!apache_arrow_1.DataType.isStruct(field.type)) {
315
+ return undefined;
316
+ }
317
+ fields = field.type.children;
318
+ }
319
+ return field;
320
+ }
321
+ function isDeferredValue(value) {
322
+ return (value == null || (Array.isArray(value) && value.every(isDeferredValue)));
323
+ }
324
+ function deferredValueMatchesType(value, type) {
325
+ if (value == null) {
326
+ return true;
327
+ }
328
+ if (!Array.isArray(value)) {
329
+ return false;
330
+ }
331
+ if (apache_arrow_1.DataType.isList(type)) {
332
+ return value.every((item) => deferredValueMatchesType(item, type.valueType));
333
+ }
334
+ if (apache_arrow_1.DataType.isFixedSizeList(type)) {
335
+ return (value.length === type.listSize &&
336
+ value.every((item) => deferredValueMatchesType(item, type.valueType)));
337
+ }
338
+ return false;
339
+ }
340
+ function inferredTypesEqual(current, candidate) {
341
+ if (apache_arrow_1.DataType.isDictionary(current)) {
342
+ return (apache_arrow_1.DataType.isDictionary(candidate) &&
343
+ current.isOrdered === candidate.isOrdered &&
344
+ inferredTypesEqual(current.indices, candidate.indices) &&
345
+ inferredTypesEqual(current.dictionary, candidate.dictionary));
346
+ }
347
+ if (apache_arrow_1.DataType.isList(current)) {
348
+ return (apache_arrow_1.DataType.isList(candidate) &&
349
+ current.valueField.name === candidate.valueField.name &&
350
+ current.valueField.nullable === candidate.valueField.nullable &&
351
+ inferredTypesEqual(current.valueType, candidate.valueType));
352
+ }
353
+ if (apache_arrow_1.DataType.isFixedSizeList(current)) {
354
+ return (apache_arrow_1.DataType.isFixedSizeList(candidate) &&
355
+ current.listSize === candidate.listSize &&
356
+ current.valueField.name === candidate.valueField.name &&
357
+ current.valueField.nullable === candidate.valueField.nullable &&
358
+ inferredTypesEqual(current.valueType, candidate.valueType));
359
+ }
360
+ return apache_arrow_1.util.compareTypes(current, candidate);
361
+ }
362
+ function describeEvidence(evidence) {
363
+ if (evidence === undefined) {
364
+ return "an unsupported value";
365
+ }
366
+ return evidence instanceof DeferredTypeEvidence
367
+ ? evidence.describe()
368
+ : evidence.toString();
369
+ }
370
+ function branchConflictError(conflict, row, candidate) {
371
+ return schemaInferenceError(conflict.path, row, conflict.value instanceof FieldTree
372
+ ? "Struct"
373
+ : describeEvidence(conflict.value), candidate);
374
+ }
375
+ function schemaInferenceError(path, row, currentType, newType) {
376
+ return new Error(`Failed to infer schema for data. Previously inferred type ${currentType} ` +
377
+ `but found ${newType} for field ${path.join(".")} at row ${row}. ` +
378
+ "Consider providing an explicit schema.");
379
+ }
380
+ function typeInferenceError(path, row) {
381
+ return new Error(`Failed to infer data type for field ${path.join(".")} at row ${row}. ` +
382
+ "Consider providing an explicit schema.");
383
+ }
384
+ function nameSuggestsVectorColumn(name) {
385
+ const normalized = name.toLowerCase();
386
+ return normalized.includes("vector") || normalized.includes("embedding");
387
+ }
package/dist/table.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Table as ArrowTable, Data, DataType, Field, IntoVector, MultiVector, Schema } from "./arrow";
2
2
  import { IndexOptions } from "./indices";
3
3
  import { MergeInsertBuilder } from "./merge";
4
- import { AddColumnsResult, AddColumnsSql, AddResult, AlterColumnsResult, BranchContents, DeleteResult, DropColumnsResult, IndexConfig, IndexStatistics, Job, LsmStats, Branches as NativeBranches, OptimizeStats, RefreshColumnResult, TableStatistics, Tags, UpdateFieldMetadataResult, UpdateResult, Table as _NativeTable } from "./native";
5
- import { FullTextQuery, Query, TakeQuery, VectorQuery } from "./query";
4
+ import { AddColumnsResult, AddColumnsSql, AddResult, AlterColumnsResult, BranchContents, DeleteResult, DropColumnsResult, IndexConfig, IndexStatistics, Job, LsmStats, Branches as NativeBranches, OptimizeStats, RefreshColumnResult, RefreshMaterializedViewResult, TableStatistics, Tags, UpdateFieldMetadataResult, UpdateResult, Table as _NativeTable } from "./native";
5
+ import { AutoQuery, FullTextQuery, Query, TakeQuery, VectorQuery } from "./query";
6
6
  import { IntoSql } from "./util";
7
7
  export { IndexConfig } from "./native";
8
8
  export { BucketStats, GenerationStats, LsmStats, MemtableStats, } from "./native";
@@ -422,7 +422,7 @@ export declare abstract class Table {
422
422
  * when "auto" is used, if the query is a string and an embedding function is defined, it will be treated as a vector query
423
423
  * if the query is a string and no embedding function is defined, it will be treated as a full text search query
424
424
  */
425
- abstract search(query: string | IntoVector | MultiVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
425
+ abstract search(query: string | IntoVector | MultiVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query | AutoQuery;
426
426
  /**
427
427
  * Search the table with a given query vector.
428
428
  *
@@ -494,6 +494,14 @@ export declare abstract class Table {
494
494
  * ```
495
495
  */
496
496
  abstract refreshColumnAsync(column: string): Promise<Job>;
497
+ /**
498
+ * Recompute this table's contents from its materialized-view definition.
499
+ *
500
+ * Plumbing for {@link MaterializedView.refresh}, which is the way to call
501
+ * it: rejects tables that carry no view definition. Local tables only.
502
+ * @ignore
503
+ */
504
+ abstract refreshMaterializedView(full?: boolean, sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
497
505
  /**
498
506
  * Alter the name or nullability of columns.
499
507
  * @param {ColumnAlteration[]} columnAlterations One or more alterations to
@@ -504,6 +512,18 @@ export declare abstract class Table {
504
512
  abstract alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
505
513
  /**
506
514
  * Update per-field (column) metadata.
515
+ *
516
+ * The following keys are treated specially, by convention, and should be
517
+ * used when appropriate:
518
+ *
519
+ * - `lancedb:description`: for a human-readable description of a field.
520
+ * - `lancedb:tag:<name>`: for a user-defined key-value tag, where the suffix
521
+ * names the tag category; e.g. `lancedb:tag:model: "clip"`.
522
+ * - `lancedb:logical-column`: for a column grouping; e.g. `feature_v1` and
523
+ * `feature_v2` might be in the same logical column.
524
+ * - `lancedb:status`: for status options (`production`, `candidate`,
525
+ * `deprecated`, `archived`) to designate the current life cycle state of
526
+ * this column.
507
527
  * @param {FieldMetadataUpdate[]} updates One or more per-field updates. Each
508
528
  * update's metadata is merged into the field's existing metadata by default;
509
529
  * a value of `null` deletes that key, and `replace: true` swaps the whole map.
@@ -831,13 +851,14 @@ export declare class LocalTable extends Table {
831
851
  takeOffsets(offsets: number[]): TakeQuery;
832
852
  takeRowIds(rowIds: readonly (bigint | number)[]): TakeQuery;
833
853
  query(): Query;
834
- search(query: string | IntoVector | MultiVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
854
+ search(query: string | IntoVector | MultiVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query | AutoQuery;
835
855
  vectorSearch(vector: IntoVector | MultiVector): VectorQuery;
836
856
  addColumns(newColumnTransforms: AddColumnsSql[] | Field | Field[] | Schema | {
837
857
  computed: AddColumnsSql[];
838
858
  }): Promise<AddColumnsResult>;
839
859
  refreshColumn(column: string): Promise<RefreshColumnResult>;
840
860
  refreshColumnAsync(column: string): Promise<Job>;
861
+ refreshMaterializedView(full?: boolean, sourceVersion?: number): Promise<RefreshMaterializedViewResult>;
841
862
  alterColumns(columnAlterations: ColumnAlteration[]): Promise<AlterColumnsResult>;
842
863
  updateFieldMetadata(updates: FieldMetadataUpdate[]): Promise<UpdateFieldMetadataResult>;
843
864
  dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
@@ -932,7 +953,8 @@ export interface FieldMetadataUpdate {
932
953
  path: string;
933
954
  /**
934
955
  * Metadata key/value pairs. Merged into the field's existing metadata by
935
- * default; a value of `null` deletes that key.
956
+ * default; a value of `null` deletes that key. See
957
+ * {@link Table.updateFieldMetadata} for the conventional `lancedb:*` keys.
936
958
  */
937
959
  metadata: Record<string, string | null>;
938
960
  /** If true, replace the field's entire metadata map instead of merging. */
@@ -966,8 +988,8 @@ export interface BranchRowCountSummary {
966
988
  inputsChanged: number;
967
989
  deltaAvailable: boolean;
968
990
  }
969
- /** A reason why a branch cannot currently be merged. */
970
- export interface MergeBlocker {
991
+ /** A reason why a cherry-pick cannot currently land. */
992
+ export interface CherryPickError {
971
993
  code: string;
972
994
  message: string;
973
995
  }
@@ -986,18 +1008,17 @@ export interface BranchDiff {
986
1008
  changedColumns: BranchColumnChange[];
987
1009
  addedIndexes: BranchIndexSummary[];
988
1010
  removedIndexes: BranchIndexSummary[];
989
- mergeable: boolean;
990
- mergeBlockers: MergeBlocker[];
1011
+ errors: CherryPickError[];
991
1012
  }
992
- /** Changes that would be, or were, promoted by a branch merge. */
993
- export interface MergePreview {
1013
+ /** Changes that would be, or were, promoted by a cherry-pick. */
1014
+ export interface CherryPickPreview {
994
1015
  promotedColumns: string[];
995
1016
  }
996
- /** Result of previewing or attempting a branch merge. */
997
- export interface MergeBranchResult {
998
- status: "ready" | "rejected" | "notImplemented" | "merged" | "unknown";
1017
+ /** Result of previewing or attempting a cherry-pick. */
1018
+ export interface CherryPickResult {
1019
+ status: "ready" | "failed" | "notImplemented" | "cherryPicked" | "unknown";
999
1020
  diff: BranchDiff;
1000
- preview: MergePreview;
1021
+ preview: CherryPickPreview;
1001
1022
  mainVersionAfter?: number;
1002
1023
  }
1003
1024
  /**
@@ -1036,13 +1057,13 @@ export declare class Branches {
1036
1057
  /** Compare a branch against main without modifying either branch. */
1037
1058
  diff(fromBranch: string): Promise<BranchDiff>;
1038
1059
  /**
1039
- * Merge a branch into main.
1060
+ * Cherry-pick a branch onto main.
1040
1061
  *
1041
- * Set `dryRun` to `true` to preview the merge. A rejected merge resolves
1042
- * with `status: "rejected"` instead of throwing.
1062
+ * Set `dryRun` to `true` to preview. A failed cherry-pick resolves
1063
+ * with `status: "failed"` instead of throwing.
1043
1064
  *
1044
- * @param fromBranch Branch to merge from.
1045
- * @param dryRun When true, only preview the merge. Defaults to false.
1065
+ * @param fromBranch Branch to cherry-pick from.
1066
+ * @param dryRun When true, only preview. Defaults to false.
1046
1067
  */
1047
- merge(fromBranch: string, dryRun?: boolean): Promise<MergeBranchResult>;
1068
+ cherryPick(fromBranch: string, dryRun?: boolean): Promise<CherryPickResult>;
1048
1069
  }
package/dist/table.js CHANGED
@@ -51,8 +51,9 @@ class LocalTable extends Table {
51
51
  display() {
52
52
  return this.inner.display();
53
53
  }
54
- async getEmbeddingFunctions() {
55
- const schema = await this.schema();
54
+ async getEmbeddingFunctions(inner = this.inner) {
55
+ const schemaBuf = await inner.schema();
56
+ const schema = (0, arrow_1.tableFromIPC)(schemaBuf).schema;
56
57
  const registry = (0, registry_1.getRegistry)();
57
58
  return registry.parseFunctions(schema.metadata);
58
59
  }
@@ -193,12 +194,24 @@ class LocalTable extends Table {
193
194
  columns: ftsColumns,
194
195
  });
195
196
  }
196
- // The query type is auto or vector
197
- // fall back to full text search if no embedding functions are defined and the query is a string
198
- if (queryType === "auto" &&
199
- ((0, registry_1.getRegistry)().length() === 0 || (0, query_1.instanceOfFullTextQuery)(query))) {
200
- return this.query().fullTextSearch(query, {
201
- columns: ftsColumns,
197
+ if (queryType === "auto") {
198
+ if ((0, query_1.instanceOfFullTextQuery)(query)) {
199
+ return this.query().fullTextSearch(query, {
200
+ columns: ftsColumns,
201
+ });
202
+ }
203
+ const columns = typeof ftsColumns === "string" ? [ftsColumns] : (ftsColumns ?? null);
204
+ return (0, query_1.createAutoQuery)(this.inner, query, columns, async (metadata) => {
205
+ const functions = await (0, registry_1.getRegistry)().parseFunctions(new Map([["embedding_functions", metadata]]));
206
+ // TODO: Support multiple embedding functions
207
+ const embeddingFunc = functions
208
+ .values()
209
+ .next().value;
210
+ // The route only calls this callback when embedding metadata exists.
211
+ // parseFunctions either yields a provider or reports malformed metadata.
212
+ if (!embeddingFunc)
213
+ throw new Error("Invalid embedding function metadata");
214
+ return await embeddingFunc.function.computeQueryEmbeddings(query);
202
215
  });
203
216
  }
204
217
  const queryPromise = this.getEmbeddingFunctions().then(async (functions) => {
@@ -262,6 +275,9 @@ class LocalTable extends Table {
262
275
  async refreshColumnAsync(column) {
263
276
  return await this.inner.refreshColumnAsync(column);
264
277
  }
278
+ async refreshMaterializedView(full, sourceVersion) {
279
+ return await this.inner.refreshMaterializedView(full, sourceVersion);
280
+ }
265
281
  async alterColumns(columnAlterations) {
266
282
  const processedAlterations = columnAlterations.map((alteration) => {
267
283
  if (typeof alteration.dataType === "string") {
@@ -467,16 +483,16 @@ class Branches {
467
483
  return (await this.#inner.diff(fromBranch));
468
484
  }
469
485
  /**
470
- * Merge a branch into main.
486
+ * Cherry-pick a branch onto main.
471
487
  *
472
- * Set `dryRun` to `true` to preview the merge. A rejected merge resolves
473
- * with `status: "rejected"` instead of throwing.
488
+ * Set `dryRun` to `true` to preview. A failed cherry-pick resolves
489
+ * with `status: "failed"` instead of throwing.
474
490
  *
475
- * @param fromBranch Branch to merge from.
476
- * @param dryRun When true, only preview the merge. Defaults to false.
491
+ * @param fromBranch Branch to cherry-pick from.
492
+ * @param dryRun When true, only preview. Defaults to false.
477
493
  */
478
- async merge(fromBranch, dryRun = false) {
479
- return (await this.#inner.merge(fromBranch, dryRun));
494
+ async cherryPick(fromBranch, dryRun = false) {
495
+ return (await this.#inner.cherryPick(fromBranch, dryRun));
480
496
  }
481
497
  }
482
498
  exports.Branches = Branches;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.38.0-beta.3",
14
+ "version": "0.38.0",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -67,7 +67,7 @@
67
67
  "timeout": "3m"
68
68
  },
69
69
  "engines": {
70
- "node": ">= 18"
70
+ "node": ">= 22"
71
71
  },
72
72
  "packageManager": "pnpm@11.1.1",
73
73
  "cpu": [
@@ -106,16 +106,16 @@
106
106
  "optionalDependencies": {
107
107
  "@huggingface/transformers": "3.0.2",
108
108
  "openai": "4.29.2",
109
- "@lancedb/lancedb-darwin-arm64": "0.38.0-beta.3",
110
- "@lancedb/lancedb-linux-x64-gnu": "0.38.0-beta.3",
111
- "@lancedb/lancedb-linux-arm64-gnu": "0.38.0-beta.3",
112
- "@lancedb/lancedb-linux-x64-musl": "0.38.0-beta.3",
113
- "@lancedb/lancedb-linux-arm64-musl": "0.38.0-beta.3",
114
- "@lancedb/lancedb-win32-x64-msvc": "0.38.0-beta.3",
115
- "@lancedb/lancedb-win32-arm64-msvc": "0.38.0-beta.3"
109
+ "@lancedb/lancedb-darwin-arm64": "0.38.0",
110
+ "@lancedb/lancedb-linux-x64-gnu": "0.38.0",
111
+ "@lancedb/lancedb-linux-arm64-gnu": "0.38.0",
112
+ "@lancedb/lancedb-linux-x64-musl": "0.38.0",
113
+ "@lancedb/lancedb-linux-arm64-musl": "0.38.0",
114
+ "@lancedb/lancedb-win32-x64-msvc": "0.38.0",
115
+ "@lancedb/lancedb-win32-arm64-msvc": "0.38.0"
116
116
  },
117
117
  "peerDependencies": {
118
- "@types/node": ">=18",
118
+ "@types/node": ">=22",
119
119
  "apache-arrow": ">=15.0.0 <=18.1.0"
120
120
  },
121
121
  "peerDependenciesMeta": {