@lancedb/lancedb 0.42.0-beta.2 → 0.42.0-beta.20
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 +3 -1
- package/dist/blob.d.ts +11 -0
- package/dist/blob.js +27 -0
- package/dist/compaction.d.ts +23 -0
- package/dist/compaction.js +21 -0
- package/dist/connection.d.ts +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/job.d.ts +38 -3
- package/dist/job.js +55 -11
- package/dist/merge.d.ts +17 -0
- package/dist/merge.js +7 -1
- package/dist/native.d.ts +220 -6
- package/dist/native.js +52 -52
- package/dist/prewarm.d.ts +19 -0
- package/dist/prewarm.js +19 -0
- package/dist/query.d.ts +12 -2
- package/dist/query.js +55 -4
- package/dist/table.d.ts +245 -11
- package/dist/table.js +85 -8
- package/package.json +9 -9
- package/pnpm-workspace.yaml +0 -7
package/dist/arrow.js
CHANGED
|
@@ -1070,7 +1070,9 @@ async function fromBufferToRecordBatch(data) {
|
|
|
1070
1070
|
* Create a buffer containing a single record batch
|
|
1071
1071
|
*/
|
|
1072
1072
|
async function fromRecordBatchToBuffer(batch) {
|
|
1073
|
-
|
|
1073
|
+
// Arrow writers require data types from their own library instance.
|
|
1074
|
+
const table = (0, sanitize_1.sanitizeTable)({ schema: batch.schema, batches: [batch] });
|
|
1075
|
+
const writer = new apache_arrow_1.RecordBatchFileWriter().writeAll(table);
|
|
1074
1076
|
return Buffer.from(await writer.toUint8Array());
|
|
1075
1077
|
}
|
|
1076
1078
|
/**
|
package/dist/blob.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ export declare function blob(name: string, options?: BlobOptions): Field;
|
|
|
124
124
|
* field's storage type.
|
|
125
125
|
*/
|
|
126
126
|
export declare function isBlobField(field: Field): boolean;
|
|
127
|
+
/** @ignore */
|
|
128
|
+
export declare function isBlobDescriptorField(field: Field): boolean;
|
|
127
129
|
/**
|
|
128
130
|
* A lazy handle to blob bytes. Create one with {@link Table.fetchBlobFiles}.
|
|
129
131
|
*
|
|
@@ -179,6 +181,15 @@ export type BlobReadOptions = {
|
|
|
179
181
|
};
|
|
180
182
|
/** @ignore */
|
|
181
183
|
export declare function runWithSignal<T>(signal: AbortSignal | undefined, run: (signal: AbortSignal | undefined) => Promise<T>): Promise<T>;
|
|
184
|
+
/** One row-specific range for {@link Table.fetchBlobRanges}. */
|
|
185
|
+
export type BlobRangeRequest = {
|
|
186
|
+
/** A row ID from a query with row IDs enabled. */
|
|
187
|
+
rowId: bigint | number;
|
|
188
|
+
/** Byte offset from the beginning of the logical blob, as a uint64. */
|
|
189
|
+
offset: bigint;
|
|
190
|
+
/** Number of bytes to read, as a uint64. Zero returns an empty non-null value. */
|
|
191
|
+
length: bigint;
|
|
192
|
+
};
|
|
182
193
|
/** A half-open byte range `[start, end)` for {@link BlobFile.readRanges}. */
|
|
183
194
|
export type BlobRange = {
|
|
184
195
|
start: bigint;
|
package/dist/blob.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.BlobFile = void 0;
|
|
6
6
|
exports.blob = blob;
|
|
7
7
|
exports.isBlobField = isBlobField;
|
|
8
|
+
exports.isBlobDescriptorField = isBlobDescriptorField;
|
|
8
9
|
exports.runWithSignal = runWithSignal;
|
|
9
10
|
exports.normalizeBlobInput = normalizeBlobInput;
|
|
10
11
|
exports.blobToRead = blobToRead;
|
|
@@ -82,6 +83,32 @@ function blob(name, options = {}) {
|
|
|
82
83
|
function isBlobField(field) {
|
|
83
84
|
return field.metadata?.get("ARROW:extension:name") === BLOB_V2_EXTENSION_NAME;
|
|
84
85
|
}
|
|
86
|
+
/** @ignore */
|
|
87
|
+
function isBlobDescriptorField(field) {
|
|
88
|
+
// Native descriptor scans replace the logical extension metadata. Require
|
|
89
|
+
// both the encoding marker and the v2 layout to exclude v1 and plain structs.
|
|
90
|
+
if (field.metadata?.get("lance-encoding:blob") !== "true" ||
|
|
91
|
+
!apache_arrow_1.DataType.isStruct(field.type)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const children = field.type.children;
|
|
95
|
+
const integers = [
|
|
96
|
+
["kind", 8],
|
|
97
|
+
["position", 64],
|
|
98
|
+
["size", 64],
|
|
99
|
+
["blob_id", 32],
|
|
100
|
+
];
|
|
101
|
+
return (children.length === 5 &&
|
|
102
|
+
integers.every(([name, width], index) => {
|
|
103
|
+
const child = children[index];
|
|
104
|
+
return (child.name === name &&
|
|
105
|
+
apache_arrow_1.DataType.isInt(child.type) &&
|
|
106
|
+
!child.type.isSigned &&
|
|
107
|
+
child.type.bitWidth === width);
|
|
108
|
+
}) &&
|
|
109
|
+
children[4].name === "blob_uri" &&
|
|
110
|
+
apache_arrow_1.DataType.isUtf8(children[4].type));
|
|
111
|
+
}
|
|
85
112
|
/**
|
|
86
113
|
* A lazy handle to blob bytes. Create one with {@link Table.fetchBlobFiles}.
|
|
87
114
|
*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Actual committed outcome of one remote compaction job. */
|
|
2
|
+
export interface CompactionResult {
|
|
3
|
+
/** A bounded run left eligible work for another invocation. */
|
|
4
|
+
moreWork: boolean;
|
|
5
|
+
/** Some planned groups were not committed. */
|
|
6
|
+
partialCommit: boolean;
|
|
7
|
+
/** Live source rows in committed rewrite groups. */
|
|
8
|
+
rowsSucceeded: number;
|
|
9
|
+
/** Planned live rows not committed by this job. */
|
|
10
|
+
rowsFailed: number;
|
|
11
|
+
/** Percentage of planned live rows committed, from 0 to 100. */
|
|
12
|
+
completionPercentage: number;
|
|
13
|
+
/** Files added, including deletion files; null if an older worker omitted it. */
|
|
14
|
+
filesAdded: number | null;
|
|
15
|
+
/** Files removed, including deletion files; null if an older worker omitted it. */
|
|
16
|
+
filesRemoved: number | null;
|
|
17
|
+
/** Fragments added by committed rewrites; null if an older worker omitted it. */
|
|
18
|
+
fragmentsAdded: number | null;
|
|
19
|
+
/** Fragments removed by committed rewrites; null if an older worker omitted it. */
|
|
20
|
+
fragmentsRemoved: number | null;
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function decodeCompactionResult(value: unknown): CompactionResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.decodeCompactionResult = decodeCompactionResult;
|
|
6
|
+
/** @internal */
|
|
7
|
+
function decodeCompactionResult(value) {
|
|
8
|
+
// The Rust typed-job decoder validates the wire payload before it reaches JS.
|
|
9
|
+
const result = value;
|
|
10
|
+
return {
|
|
11
|
+
moreWork: result.more_work,
|
|
12
|
+
partialCommit: result.partial_commit,
|
|
13
|
+
rowsSucceeded: result.rows_succeeded,
|
|
14
|
+
rowsFailed: result.rows_failed,
|
|
15
|
+
completionPercentage: result.completion_percentage,
|
|
16
|
+
filesAdded: result.files_added ?? null,
|
|
17
|
+
filesRemoved: result.files_removed ?? null,
|
|
18
|
+
fragmentsAdded: result.fragments_added ?? null,
|
|
19
|
+
fragmentsRemoved: result.fragments_removed ?? null,
|
|
20
|
+
};
|
|
21
|
+
}
|
package/dist/connection.d.ts
CHANGED
|
@@ -440,7 +440,7 @@ export declare abstract class Connection {
|
|
|
440
440
|
* result, failure and event history, so there is no separate
|
|
441
441
|
* connection-level call for any of them.
|
|
442
442
|
*/
|
|
443
|
-
abstract openJob(jobId: string): Promise<Job
|
|
443
|
+
abstract openJob<T = void>(jobId: string): Promise<Job<T>>;
|
|
444
444
|
/**
|
|
445
445
|
* Iterate lazily over server-side jobs across the database's tables.
|
|
446
446
|
* Use `for await...of`. Options control page size and the starting token.
|
|
@@ -518,7 +518,7 @@ export declare class LocalConnection extends Connection {
|
|
|
518
518
|
createNamespace(namespacePath: string[], options?: Partial<CreateNamespaceOptions>): Promise<CreateNamespaceResponse>;
|
|
519
519
|
dropNamespace(namespacePath: string[], options?: Partial<DropNamespaceOptions>): Promise<DropNamespaceResponse>;
|
|
520
520
|
renameTable(currentName: string, newName: string, options?: RenameTableOptions): Promise<void>;
|
|
521
|
-
openJob(jobId: string): Promise<Job
|
|
521
|
+
openJob<T = void>(jobId: string): Promise<Job<T>>;
|
|
522
522
|
listJobs(options?: ListingOptions): Listing<JobInfo>;
|
|
523
523
|
cancelJob(jobId: string): Promise<boolean>;
|
|
524
524
|
pauseJob(jobId: string): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,17 +7,17 @@ export { MaterializedView, MaterializedViewDefinition, MaterializedViewSelect, }
|
|
|
7
7
|
export { ViewDescription } from "./view";
|
|
8
8
|
export { JsHeaderProvider as NativeJsHeaderProvider } from "./native.js";
|
|
9
9
|
export { instrumentLanceDbMetrics } from "./otel";
|
|
10
|
-
export { AddColumnsSql, ConnectionOptions, ConnectNamespaceOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, TlsConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, BranchContents, MergeResult, AddResult, AddColumnsResult, RefreshColumnResult, FunctionErrors, FunctionErrorsOptions, FunctionErrorRecord, FunctionErrorFragment, RefreshMaterializedViewResult, AlterColumnsResult, UpdateFieldMetadataResult, DeleteResult, DropColumnsResult, UpdateResult, SplitCalculatedOptions, SplitRandomOptions, SplitHashOptions, SplitSequentialOptions, ShuffleOptions, OAuthConfig as NativeOAuthConfig, } from "./native.js";
|
|
10
|
+
export { AddColumnsSql, ConnectionOptions, ConnectNamespaceOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, TlsConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, BranchContents, MergeResult, AddResult, AddColumnsResult, RefreshColumnOptions, FunctionRefreshPlanningConfig, FunctionRefreshPodResources, FunctionRetryPolicy, FunctionWorkerResourceBudget, RefreshColumnResult, FunctionErrors, FunctionErrorsOptions, FunctionErrorRecord, FunctionErrorFragment, RefreshMaterializedViewResult, AlterColumnsResult, UpdateFieldMetadataResult, DeleteResult, DropColumnsResult, UpdateResult, SplitCalculatedOptions, SplitRandomOptions, SplitHashOptions, SplitSequentialOptions, ShuffleOptions, OAuthConfig as NativeOAuthConfig, } from "./native.js";
|
|
11
11
|
export { makeArrowTable, makeJsonField, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
|
|
12
12
|
export { blob, isBlobField, BlobFile } from "./blob";
|
|
13
|
-
export type { BlobData, BlobInput, BlobOptions, BlobRange, BlobReadOptions, BlobUri, } from "./blob";
|
|
13
|
+
export type { BlobData, BlobInput, BlobOptions, BlobRange, BlobRangeRequest, BlobReadOptions, BlobUri, } from "./blob";
|
|
14
14
|
export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, CreateNamespaceOptions, DropNamespaceOptions, CreateNamespaceResponse, DropNamespaceResponse, DescribeNamespaceResponse, RenameTableOptions, } from "./connection";
|
|
15
15
|
export { JobFailureInfo, JobInfo, Session } from "./native.js";
|
|
16
16
|
export { Job, JobEventsOptions, } from "./job";
|
|
17
|
-
export type { JobProgress, JobProgressCallback } from "./job";
|
|
17
|
+
export type { JobProgress, JobProgressCallback, JobWaitOptions } from "./job";
|
|
18
18
|
export { AutoQuery, ExecutableQuery, Query, QueryBase, VectorQuery, TakeQuery, AnalyzePlanDistributedMetrics, BlobMode, QueryExecutionOptions, ColumnOrdering, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
|
|
19
19
|
export { Index, IndexOptions, IvfPqOptions, IvfRqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, BaseTokenizer, } from "./indices";
|
|
20
|
-
export { Table, Branches, BranchColumnSummary, BranchColumnChange, BranchIndexSummary, BranchRowCountSummary, CherryPickError, BranchDiff, CherryPickPreview, CherryPickResult, AddDataOptions, UpdateOptions, OptimizeOptions, Version, WriteProgress, FtsToken, TokenizeTableOptions, RTEWriteSpec, RTEStats, TableShardStats, SsTableStats, MemtableStats, ColumnAlteration, FieldMetadataUpdate, } from "./table";
|
|
20
|
+
export { Table, FunctionColumnAutoRefreshStatus, FunctionColumnLastRefreshJob, FunctionColumnStatus, FunctionColumnVersionStatus, Branches, BranchColumnSummary, BranchColumnChange, BranchIndexSummary, BranchRowCountSummary, CherryPickError, BranchDiff, CherryPickPreview, CherryPickResult, AddDataOptions, UpdateOptions, OptimizeOptions, CompactionOptions, PrewarmDataOptions, Version, WriteProgress, FtsToken, TokenizeTableOptions, RTEWriteSpec, RTEStats, TableShardStats, SsTableStats, MemtableStats, ColumnAlteration, FieldMetadataUpdate, } from "./table";
|
|
21
21
|
export { HeaderProvider, StaticHeaderProvider, OAuthHeaderProvider, TokenResponse, } from "./header";
|
|
22
22
|
export { ClientAuthMethod, OAuthConfig, OAuthFlowType, OAuthSession, SessionLogout, SessionStatus, TokenCacheOptions, } from "./oauth";
|
|
23
23
|
export { MergeInsertBuilder, WriteExecutionOptions } from "./merge";
|
|
@@ -253,3 +253,5 @@ export declare function connectNamespace(implName: "rest", config: RestNamespace
|
|
|
253
253
|
export declare function connectNamespace(implName: string, properties: Record<string, string>, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
|
|
254
254
|
export { Catalog, CatalogOptions, DatabaseNames, connectCatalog, } from "./catalog";
|
|
255
255
|
export { Listing, ListingOptions } from "./listing";
|
|
256
|
+
export type { CompactionResult } from "./compaction";
|
|
257
|
+
export type { PrewarmDataResult } from "./prewarm";
|
package/dist/job.d.ts
CHANGED
|
@@ -29,6 +29,19 @@ export interface JobProgress {
|
|
|
29
29
|
rows_skipped?: number | null;
|
|
30
30
|
rows_remaining?: number | null;
|
|
31
31
|
rows_failed?: number | null;
|
|
32
|
+
/** Maintenance work observations; rewritten rows are not committed rows. */
|
|
33
|
+
groups_planned?: number | null;
|
|
34
|
+
groups_completed?: number | null;
|
|
35
|
+
rows_rewritten?: number | null;
|
|
36
|
+
executors_targeted?: number | null;
|
|
37
|
+
executors_completed?: number | null;
|
|
38
|
+
executors_partial?: number | null;
|
|
39
|
+
executors_active?: number | null;
|
|
40
|
+
executors_failed?: number | null;
|
|
41
|
+
fragments_selected?: number | null;
|
|
42
|
+
ranges_completed?: number | null;
|
|
43
|
+
ranges_planned?: number | null;
|
|
44
|
+
bytes_read?: number | null;
|
|
32
45
|
/** Execution identity and sample time used for client-side ETA derivation. */
|
|
33
46
|
execution_epoch?: number | null;
|
|
34
47
|
sample_at_millis?: number | null;
|
|
@@ -39,6 +52,17 @@ export interface JobProgress {
|
|
|
39
52
|
}
|
|
40
53
|
/** Callback for progress snapshots observed while waiting for a job. */
|
|
41
54
|
export type JobProgressCallback = (progress: JobProgress) => void;
|
|
55
|
+
/** Client-side controls for waiting without cancelling the underlying job. */
|
|
56
|
+
export interface JobWaitOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Maximum wait in milliseconds, including status requests and polling backoff.
|
|
59
|
+
* Must be a nonnegative safe integer. Omit to wait indefinitely; zero allows
|
|
60
|
+
* only an immediately ready result.
|
|
61
|
+
*/
|
|
62
|
+
timeoutMs?: number;
|
|
63
|
+
/** Observe progress using the same poller that waits for completion. */
|
|
64
|
+
onProgress?: JobProgressCallback;
|
|
65
|
+
}
|
|
42
66
|
/**
|
|
43
67
|
* A handle to an operation that may still be running.
|
|
44
68
|
*
|
|
@@ -56,9 +80,10 @@ export type JobProgressCallback = (progress: JobProgress) => void;
|
|
|
56
80
|
*
|
|
57
81
|
* @hideconstructor
|
|
58
82
|
*/
|
|
59
|
-
export declare class Job {
|
|
83
|
+
export declare class Job<T = void> {
|
|
60
84
|
private readonly inner;
|
|
61
|
-
|
|
85
|
+
private readonly resultDecoder?;
|
|
86
|
+
constructor(inner: NativeJob, resultDecoder?: (value: unknown) => T);
|
|
62
87
|
/**
|
|
63
88
|
* Identifies the operation on the server that is running it.
|
|
64
89
|
*
|
|
@@ -112,8 +137,18 @@ export declare class Job {
|
|
|
112
137
|
* synchronous observer: its return value is ignored and not awaited. If it
|
|
113
138
|
* throws, the error is logged with `console.warn` and waiting continues; a
|
|
114
139
|
* callback exception does not reject `wait`.
|
|
140
|
+
*
|
|
141
|
+
* Pass an options object to set a client-side timeout. Expiry rejects with an
|
|
142
|
+
* error and stops this wait, including pending status requests and backoff.
|
|
143
|
+
* The operation continues; use the same handle to wait again. Registry jobs
|
|
144
|
+
* can also be reopened with `Connection.openJob`; query IDs cannot.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const result = await job.wait({ timeoutMs: 60_000, onProgress: console.log });
|
|
149
|
+
* ```
|
|
115
150
|
*/
|
|
116
|
-
wait(
|
|
151
|
+
wait(optionsOrProgress?: JobWaitOptions | JobProgressCallback): Promise<T>;
|
|
117
152
|
/** Request cancellation. Cancelling a finished operation is a no-op. */
|
|
118
153
|
cancel(): Promise<void>;
|
|
119
154
|
/**
|
package/dist/job.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.Job = void 0;
|
|
6
6
|
const apache_arrow_1 = require("apache-arrow");
|
|
7
|
+
const compaction_1 = require("./compaction");
|
|
8
|
+
const prewarm_1 = require("./prewarm");
|
|
7
9
|
/**
|
|
8
10
|
* A handle to an operation that may still be running.
|
|
9
11
|
*
|
|
@@ -23,8 +25,16 @@ const apache_arrow_1 = require("apache-arrow");
|
|
|
23
25
|
*/
|
|
24
26
|
class Job {
|
|
25
27
|
inner;
|
|
26
|
-
|
|
28
|
+
resultDecoder;
|
|
29
|
+
constructor(inner, resultDecoder) {
|
|
27
30
|
this.inner = inner;
|
|
31
|
+
this.resultDecoder =
|
|
32
|
+
resultDecoder ??
|
|
33
|
+
(inner.jobType === "prewarm_page_cache"
|
|
34
|
+
? prewarm_1.decodePrewarmDataResult
|
|
35
|
+
: inner.jobType === "compact"
|
|
36
|
+
? compaction_1.decodeCompactionResult
|
|
37
|
+
: undefined);
|
|
28
38
|
}
|
|
29
39
|
/**
|
|
30
40
|
* Identifies the operation on the server that is running it.
|
|
@@ -100,19 +110,53 @@ class Job {
|
|
|
100
110
|
* synchronous observer: its return value is ignored and not awaited. If it
|
|
101
111
|
* throws, the error is logged with `console.warn` and waiting continues; a
|
|
102
112
|
* callback exception does not reject `wait`.
|
|
113
|
+
*
|
|
114
|
+
* Pass an options object to set a client-side timeout. Expiry rejects with an
|
|
115
|
+
* error and stops this wait, including pending status requests and backoff.
|
|
116
|
+
* The operation continues; use the same handle to wait again. Registry jobs
|
|
117
|
+
* can also be reopened with `Connection.openJob`; query IDs cannot.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const result = await job.wait({ timeoutMs: 60_000, onProgress: console.log });
|
|
122
|
+
* ```
|
|
103
123
|
*/
|
|
104
|
-
async wait(
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
async wait(optionsOrProgress) {
|
|
125
|
+
const options = typeof optionsOrProgress === "function"
|
|
126
|
+
? { onProgress: optionsOrProgress }
|
|
127
|
+
: (optionsOrProgress ?? {});
|
|
128
|
+
if (typeof options !== "object" || Array.isArray(options)) {
|
|
129
|
+
throw new TypeError("wait expects an options object or a progress callback");
|
|
107
130
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
131
|
+
for (const key of Object.keys(options)) {
|
|
132
|
+
if (key !== "timeoutMs" && key !== "onProgress") {
|
|
133
|
+
throw new TypeError(`Unknown job wait option: ${key}`);
|
|
111
134
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
}
|
|
136
|
+
const { timeoutMs, onProgress: progressCallback } = options;
|
|
137
|
+
if (timeoutMs !== undefined &&
|
|
138
|
+
(!Number.isSafeInteger(timeoutMs) || timeoutMs < 0)) {
|
|
139
|
+
throw new RangeError("timeoutMs must be a nonnegative safe integer");
|
|
140
|
+
}
|
|
141
|
+
if (progressCallback !== undefined &&
|
|
142
|
+
typeof progressCallback !== "function") {
|
|
143
|
+
throw new TypeError("onProgress must be a function");
|
|
144
|
+
}
|
|
145
|
+
const callback = progressCallback === undefined
|
|
146
|
+
? undefined
|
|
147
|
+
: (progress) => {
|
|
148
|
+
try {
|
|
149
|
+
progressCallback(this.enrichProgress(progress));
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.warn("Job progress callback threw:", error);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
if (this.resultDecoder !== undefined) {
|
|
156
|
+
return this.resultDecoder(await this.inner.waitResult(callback, timeoutMs));
|
|
157
|
+
}
|
|
158
|
+
await this.inner.wait(callback, timeoutMs);
|
|
159
|
+
return undefined;
|
|
116
160
|
}
|
|
117
161
|
/** Request cancellation. Cancelling a finished operation is a no-op. */
|
|
118
162
|
async cancel() {
|
package/dist/merge.d.ts
CHANGED
|
@@ -99,6 +99,23 @@ export interface WriteExecutionOptions {
|
|
|
99
99
|
* first attempt will not be cancelled.
|
|
100
100
|
*
|
|
101
101
|
* When this is set, the timeout is enforced on all attempts, including the first.
|
|
102
|
+
* For remote tables this is sent as a server execution timeout. It does not
|
|
103
|
+
* extend HTTP read or proxy idle timeouts, or prove that a failed request did
|
|
104
|
+
* not commit.
|
|
102
105
|
*/
|
|
103
106
|
timeoutMs?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Override the remote retry budget for this execution only (an integer from
|
|
109
|
+
* 0 to 255). Use `execute(data, { retries: 0 })` to disable even retries after
|
|
110
|
+
* precommit conflicts (409) or rate limits (429). This does not change
|
|
111
|
+
* connection-wide/read budgets or local transaction conflict retries.
|
|
112
|
+
*
|
|
113
|
+
* By default, remote calls use the connection's `clientConfig.retryConfig`
|
|
114
|
+
* ({@link RetryConfig}). Its `statuses` (also set through
|
|
115
|
+
* `LANCE_CLIENT_RETRY_STATUSES`) selects candidates within the retry budget;
|
|
116
|
+
* it never permits replay of ambiguous merge outcomes. In particular, 502,
|
|
117
|
+
* ordinary 503, and 504 are never replayed, even if configured. Reconcile table
|
|
118
|
+
* contents before manually repeating a merge whose commit outcome is unknown.
|
|
119
|
+
*/
|
|
120
|
+
retries?: number;
|
|
104
121
|
}
|
package/dist/merge.js
CHANGED
|
@@ -102,6 +102,12 @@ class MergeInsertBuilder {
|
|
|
102
102
|
* @returns {Promise<MergeResult>} the merge result
|
|
103
103
|
*/
|
|
104
104
|
async execute(data, execOptions) {
|
|
105
|
+
if (execOptions?.retries !== undefined &&
|
|
106
|
+
(!Number.isInteger(execOptions.retries) ||
|
|
107
|
+
execOptions.retries < 0 ||
|
|
108
|
+
execOptions.retries > 255)) {
|
|
109
|
+
throw new Error("retries must be an integer between 0 and 255");
|
|
110
|
+
}
|
|
105
111
|
let schema;
|
|
106
112
|
if (this.#schema instanceof Promise) {
|
|
107
113
|
schema = await this.#schema;
|
|
@@ -114,7 +120,7 @@ class MergeInsertBuilder {
|
|
|
114
120
|
this.#native.setTimeout(execOptions.timeoutMs);
|
|
115
121
|
}
|
|
116
122
|
const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
|
|
117
|
-
return await this.#native.execute(buffer);
|
|
123
|
+
return await this.#native.execute(buffer, execOptions?.retries);
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
exports.MergeInsertBuilder = MergeInsertBuilder;
|