mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
feat(nodejs): expose Function failure recovery APIs (#5209)
TypeScript callers can now inspect and recover Function row failures through the native workflow. `functionErrors()` groups returned failures and can show retained attempt history. `functionErrorRows()` looks up current failed inputs using row IDs and physical row addresses represented as `bigint`. Older deployments can continue to use the existing error listing. `retryFailed()` selects the exact failed rows on the server, with optional error type and job filters. `upgradeColumn()` binds an existing immutable Function version and can recompute failed rows, all eligible rows, or no rows. Callers can quarantine and release failures, explicitly include quarantined rows in a retry, and use `functionProvenance()` to see which Function version produced a recorded value. The native operations reuse the existing Rust workflow v1 capability checks. The Function failures guide includes TypeScript examples for inspecting, retrying, upgrading, and quarantining failures.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import * as http from "http";
|
||||
import { RequestListener } from "http";
|
||||
import { tableFromArrays } from "apache-arrow";
|
||||
import packageJson = require("../package.json");
|
||||
import {
|
||||
ClientAuthMethod,
|
||||
@@ -854,15 +855,349 @@ describe("remote connection", () => {
|
||||
]);
|
||||
expect(errors.records[0].rowOffset).toBe(9);
|
||||
expect(errors.fragments[0].rowsSkipped).toBe(500);
|
||||
await table.functionErrors();
|
||||
expect(errors.workflowVersion).toBeUndefined();
|
||||
expect(errors.errorGroups).toBeUndefined();
|
||||
await expect(
|
||||
table.functionErrorRows({ columns: ["text"] }),
|
||||
).rejects.toThrow("Function row-failure workflow");
|
||||
await table.functionErrors({ history: false });
|
||||
await expect(table.functionErrors({ limit: -1 })).rejects.toThrow(
|
||||
"limit must be a non-negative integer",
|
||||
);
|
||||
for (const operation of [
|
||||
() => table.functionErrors({ history: true }),
|
||||
() => table.retryFailed("embedding"),
|
||||
() => table.upgradeColumn("embedding", { version: "2" }),
|
||||
() => table.quarantineFailed("embedding"),
|
||||
() => table.quarantineFailed("embedding", { quarantined: false }),
|
||||
() => table.functionProvenance("embedding"),
|
||||
]) {
|
||||
await expect(operation()).rejects.toThrow(
|
||||
"Function row-failure workflow",
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
expect(bodies).toEqual([
|
||||
JSON.parse('{"job_id": "j-7", "column": "embedding", "limit": 2}'),
|
||||
{},
|
||||
{},
|
||||
...Array.from({ length: 6 }, () => ({ limit: 1 })),
|
||||
]);
|
||||
});
|
||||
|
||||
it("reads Function failure history and joins current inputs by exact row identity", async () => {
|
||||
const stableId = 9_007_199_254_740_993n;
|
||||
const physicalAddress = 9_007_203_549_708_297n;
|
||||
const currentRows = tableFromArrays({
|
||||
text: ["physical failure", "moved stable row", "unrelated row"],
|
||||
["_rowid"]: new BigUint64Array([
|
||||
physicalAddress,
|
||||
stableId,
|
||||
stableId - 1n,
|
||||
]),
|
||||
["_rowaddr"]: new BigUint64Array([physicalAddress, 14n, 10n]),
|
||||
});
|
||||
const records = `[
|
||||
{"job_id":"j-7", "fragment_id":0, "row_offset":10,
|
||||
"row_id":${stableId}, "row_address":10, "column":"embedding",
|
||||
"function":"embed", "function_version":"2", "table_version":11,
|
||||
"error_type":"ValueError", "error_message":"bad input",
|
||||
"created_at_millis":1700000000001, "first_seen_at_millis":1700000000000,
|
||||
"last_seen_at_millis":1700000000001, "attempts":3, "quarantined":true},
|
||||
{"job_id":"j-7", "fragment_id":2097153, "row_offset":9,
|
||||
"row_address":${physicalAddress}, "column":"embedding",
|
||||
"function":"embed", "function_version":"2", "table_version":11,
|
||||
"error_type":"ValueError", "error_message":"bad input", "created_at_millis":1700000000001},
|
||||
{"job_id":"j-8", "fragment_id":0, "row_offset":10,
|
||||
"row_id":${stableId}, "row_address":10, "column":"score",
|
||||
"function":"score", "function_version":"1", "table_version":11,
|
||||
"error_type":"TypeError", "error_message":"bad input", "created_at_millis":1700000000001}
|
||||
]`;
|
||||
const groups = `[
|
||||
{"column":"embedding", "error_type":"ValueError", "error_message":"bad input", "rows_failed":2},
|
||||
{"column":"score", "error_type":"TypeError", "error_message":"bad input", "rows_failed":1}
|
||||
]`;
|
||||
const errorRequests: unknown[] = [];
|
||||
const queryRequests: unknown[] = [];
|
||||
await withMockDatabase(
|
||||
(req, res) => {
|
||||
let body = "";
|
||||
req.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
req.on("end", () => {
|
||||
if (req.url === "/v1/table/docs/describe/") {
|
||||
res.writeHead(200).end('{"version":12,"schema":{"fields":[]}}');
|
||||
} else if (req.url === "/v1/table/docs/errors") {
|
||||
const request = JSON.parse(body);
|
||||
errorRequests.push(request);
|
||||
const empty = request.column === "empty";
|
||||
const truncated = request.limit === 2;
|
||||
res.writeHead(200).end(`{
|
||||
"workflow_version":1, "records":${empty ? "[]" : records},
|
||||
"fragments":[], "truncated":${truncated},
|
||||
"error_groups":${empty ? "[]" : groups}
|
||||
}`);
|
||||
} else if (req.url === "/v1/table/docs/query/") {
|
||||
const query = JSON.parse(body);
|
||||
queryRequests.push(query);
|
||||
const rows =
|
||||
queryRequests.length === 1
|
||||
? currentRows.slice(0, 2)
|
||||
: currentRows.slice(0, 1);
|
||||
res
|
||||
.writeHead(200, {
|
||||
"Content-Type": "application/vnd.apache.arrow.stream",
|
||||
})
|
||||
.end(Buffer.from(tableToIPC(rows, "stream")));
|
||||
} else {
|
||||
res.writeHead(404).end();
|
||||
}
|
||||
});
|
||||
},
|
||||
async (db) => {
|
||||
const table = await db.openTable("docs");
|
||||
const errors = await table.functionErrors();
|
||||
expect(errors.workflowVersion).toBe(1);
|
||||
expect(errors.records[0]).toMatchObject({
|
||||
rowId: stableId,
|
||||
rowAddress: 10n,
|
||||
attempts: 3,
|
||||
firstSeenAtMillis: 1_700_000_000_000,
|
||||
lastSeenAtMillis: 1_700_000_000_001,
|
||||
quarantined: true,
|
||||
});
|
||||
expect(errors.records[1].rowAddress).toBe(physicalAddress);
|
||||
expect(errors.errorGroups).toEqual([
|
||||
{
|
||||
column: "embedding",
|
||||
errorType: "ValueError",
|
||||
errorMessage: "bad input",
|
||||
rowsFailed: 2n,
|
||||
},
|
||||
{
|
||||
column: "score",
|
||||
errorType: "TypeError",
|
||||
errorMessage: "bad input",
|
||||
rowsFailed: 1n,
|
||||
},
|
||||
]);
|
||||
const rows = await table.functionErrorRows({ columns: ["text"] });
|
||||
expect(rows.map(({ input, error }) => [input, error.column])).toEqual([
|
||||
[{ text: "moved stable row" }, "embedding"],
|
||||
[{ text: "physical failure" }, "embedding"],
|
||||
[{ text: "moved stable row" }, "score"],
|
||||
]);
|
||||
await expect(
|
||||
table.functionErrorRows({ columns: ["text"] }),
|
||||
).rejects.toThrow("no longer addressable");
|
||||
const history = await table.functionErrors({
|
||||
history: true,
|
||||
jobId: "j-7",
|
||||
});
|
||||
expect(history.records[0].rowId).toBe(stableId);
|
||||
await expect(
|
||||
table.functionErrorRows({ columns: ["text"], limit: 2 }),
|
||||
).rejects.toThrow("Function errors are incomplete");
|
||||
await expect(
|
||||
table.functionErrorRows({ column: "empty" }),
|
||||
).resolves.toEqual([]);
|
||||
},
|
||||
);
|
||||
expect(errorRequests).toEqual([
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{ limit: 1 },
|
||||
{ history: true, ["job_id"]: "j-7" },
|
||||
{ limit: 2 },
|
||||
{ column: "empty" },
|
||||
]);
|
||||
expect(queryRequests).toHaveLength(2);
|
||||
for (const request of queryRequests) {
|
||||
expect(request).toMatchObject({
|
||||
columns: ["text", "_rowid", "_rowaddr"],
|
||||
filter: `_rowid IN (${stableId}) OR _rowaddr IN (${physicalAddress})`,
|
||||
k: 2,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it("forwards exact Function recovery requests and preserves async job results", async () => {
|
||||
const requests: [string, unknown][] = [];
|
||||
const stableId = 9_007_199_254_740_993n;
|
||||
await withMockDatabase(
|
||||
(req, res) => {
|
||||
let body = "";
|
||||
req.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
req.on("end", () => {
|
||||
const path = req.url ?? "";
|
||||
const request = body ? JSON.parse(body) : {};
|
||||
requests.push([path, request]);
|
||||
if (path === "/v1/table/docs/describe/") {
|
||||
res.writeHead(200).end('{"version":8,"schema":{"fields":[]}}');
|
||||
} else if (path === "/v1/table/docs/errors") {
|
||||
res
|
||||
.writeHead(200)
|
||||
.end(
|
||||
'{"workflow_version":1,"records":[],"fragments":[],"truncated":false}',
|
||||
);
|
||||
} else if (path === "/v1/table/docs/backfill_column") {
|
||||
res.writeHead(202).end('{"job_id":"refresh-1"}');
|
||||
} else if (path === "/v1/jobs/describe") {
|
||||
res.writeHead(200).end(`{
|
||||
"job_id":"refresh-1", "job_type":"function_refresh", "job_state":"DONE",
|
||||
"result":{"rows_assigned":19, "rows_failed":1, "rows_remaining":0,
|
||||
"source_version":7, "published_version":8, "error_groups_truncated":true,
|
||||
"error_groups":[{"column":"embedding", "error_type":"ValueError",
|
||||
"error_message":"bad input", "rows_failed":1}]}
|
||||
}`);
|
||||
} else if (path === "/v1/table/docs/errors/quarantine") {
|
||||
res.writeHead(200).end('{"rows_affected":2}');
|
||||
} else if (path === "/v1/table/docs/function_provenance") {
|
||||
res.writeHead(200).end(`{"truncated":true,"records":[{
|
||||
"column":"embedding", "job_id":"refresh-1", "function_name":"embed",
|
||||
"function_version":"2", "row_id":${stableId}, "row_address":null,
|
||||
"source_version":7, "published_version":8
|
||||
}]}`);
|
||||
} else {
|
||||
res.writeHead(404).end();
|
||||
}
|
||||
});
|
||||
},
|
||||
async (db) => {
|
||||
const table = await db.openTable("docs");
|
||||
const job = await table.retryFailed("embedding", {
|
||||
errorType: "ValueError",
|
||||
jobId: "first",
|
||||
includeQuarantined: true,
|
||||
functionVersion: "2",
|
||||
maxFailedFraction: 1,
|
||||
});
|
||||
expect(job.id).toBe("refresh-1");
|
||||
expect(await job.wait()).toEqual({
|
||||
rowsAssigned: 19n,
|
||||
rowsFailed: 1n,
|
||||
rowsRemaining: 0n,
|
||||
sourceVersion: 7n,
|
||||
publishedVersion: 8n,
|
||||
errorGroupsTruncated: true,
|
||||
errorGroups: [
|
||||
{
|
||||
column: "embedding",
|
||||
errorType: "ValueError",
|
||||
errorMessage: "bad input",
|
||||
rowsFailed: 1n,
|
||||
},
|
||||
],
|
||||
});
|
||||
await table.retryFailed("embedding");
|
||||
await table.upgradeColumn("embedding", {
|
||||
version: "3",
|
||||
recompute: "failed",
|
||||
});
|
||||
await table.upgradeColumn("embedding", { version: "4" });
|
||||
await table.upgradeColumn("embedding", {
|
||||
version: "5",
|
||||
recompute: "none",
|
||||
});
|
||||
await expect(
|
||||
table.quarantineFailed("embedding", {
|
||||
jobId: "first",
|
||||
afterAttempts: 3,
|
||||
errorType: "ValueError",
|
||||
}),
|
||||
).resolves.toBe(2);
|
||||
await expect(
|
||||
table.quarantineFailed("embedding", { quarantined: false }),
|
||||
).resolves.toBe(2);
|
||||
const provenance = await table.functionProvenance("embedding", {
|
||||
version: 8n,
|
||||
limit: 1,
|
||||
});
|
||||
expect(provenance.truncated).toBe(true);
|
||||
expect(provenance.records[0]).toMatchObject({
|
||||
jobId: "refresh-1",
|
||||
functionName: "embed",
|
||||
functionVersion: "2",
|
||||
rowId: stableId,
|
||||
sourceVersion: 7n,
|
||||
publishedVersion: 8n,
|
||||
});
|
||||
await expect(
|
||||
table.upgradeColumn("embedding", { version: "" }),
|
||||
).rejects.toThrow("nonempty function_version");
|
||||
await expect(
|
||||
table.quarantineFailed("embedding", { afterAttempts: 2 ** 32 + 1 }),
|
||||
).rejects.toThrow("afterAttempts");
|
||||
await expect(
|
||||
table.functionProvenance("embedding", { version: -(2n ** 64n) }),
|
||||
).rejects.toThrow("positive lossless u64 bigint");
|
||||
const ordinary = await table.refreshColumnAsync("embedding");
|
||||
await expect(ordinary.wait()).resolves.toBeUndefined();
|
||||
},
|
||||
);
|
||||
const probe = ["/v1/table/docs/errors", { limit: 1 }];
|
||||
expect(requests).toEqual([
|
||||
["/v1/table/docs/describe/", {}],
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/backfill_column",
|
||||
JSON.parse(`{
|
||||
"column":"embedding", "retry_errors":true, "retry_job_id":"first",
|
||||
"retry_error_type":"ValueError", "include_quarantined":true,
|
||||
"function_version":"2", "recompute":"failed", "max_failed_fraction":1
|
||||
}`),
|
||||
],
|
||||
["/v1/jobs/describe", { ["job_id"]: "refresh-1" }],
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/backfill_column",
|
||||
{ column: "embedding", ["retry_errors"]: true },
|
||||
],
|
||||
...[
|
||||
["3", "failed"],
|
||||
["4", "all"],
|
||||
["5", "none"],
|
||||
].flatMap(([version, recompute]) => [
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/backfill_column",
|
||||
{ column: "embedding", ["function_version"]: version, recompute },
|
||||
],
|
||||
]),
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/errors/quarantine",
|
||||
{
|
||||
column: "embedding",
|
||||
quarantined: true,
|
||||
["job_id"]: "first",
|
||||
["after_attempts"]: 3,
|
||||
["error_type"]: "ValueError",
|
||||
},
|
||||
],
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/errors/quarantine",
|
||||
{
|
||||
column: "embedding",
|
||||
quarantined: false,
|
||||
["job_id"]: null,
|
||||
["after_attempts"]: null,
|
||||
["error_type"]: null,
|
||||
},
|
||||
],
|
||||
probe,
|
||||
[
|
||||
"/v1/table/docs/function_provenance",
|
||||
{ column: "embedding", version: 8, limit: 1 },
|
||||
],
|
||||
["/v1/table/docs/backfill_column", { column: "embedding" }],
|
||||
["/v1/jobs/describe", { ["job_id"]: "refresh-1" }],
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -6474,18 +6474,35 @@ describe("durable compaction validation", () => {
|
||||
});
|
||||
|
||||
describe("Enterprise table overrides", () => {
|
||||
it("keeps override methods optional for existing custom Table subclasses", async () => {
|
||||
// Declare the old Table surface; only the new methods must be inherited.
|
||||
// Keeping these override methods abstract must fail type checking here.
|
||||
it("keeps added operations optional for existing custom Table subclasses", async () => {
|
||||
// Declare the old Table surface; the new methods must be inherited.
|
||||
// biome-ignore lint/correctness/noUnusedVariables: declaration merging supplies the legacy members
|
||||
interface LegacyTable
|
||||
extends Omit<
|
||||
Table,
|
||||
"getTableOverrides" | "updateTableOverrides" | "resetTableOverrides"
|
||||
| "getTableOverrides"
|
||||
| "updateTableOverrides"
|
||||
| "resetTableOverrides"
|
||||
| "functionErrors"
|
||||
| "functionErrorRows"
|
||||
| "retryFailed"
|
||||
| "upgradeColumn"
|
||||
| "quarantineFailed"
|
||||
| "functionProvenance"
|
||||
> {}
|
||||
class LegacyTable extends Table {}
|
||||
class LegacyTable extends Table {
|
||||
async functionErrors() {
|
||||
return { records: [], fragments: [], truncated: false };
|
||||
}
|
||||
}
|
||||
|
||||
const table = new LegacyTable();
|
||||
await expect(table.functionErrorRows()).rejects.toThrow(
|
||||
"Function row-failure workflow",
|
||||
);
|
||||
await expect(table.retryFailed("embedding")).rejects.toThrow(
|
||||
"retryFailed is not supported on this table type",
|
||||
);
|
||||
await expect(table.delta(1)).rejects.toThrow(
|
||||
"table.delta is only supported on LanceDB Embedded tables",
|
||||
);
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
import type {
|
||||
FunctionErrorGroup,
|
||||
FunctionErrorRecord,
|
||||
FunctionErrors,
|
||||
FunctionErrorsOptions,
|
||||
RefreshColumnOptions,
|
||||
} from "./native";
|
||||
import type { Table } from "./table";
|
||||
|
||||
/** Options for retrying exactly the current failures of one Function column. */
|
||||
export interface RetryFailedOptions
|
||||
extends Omit<RefreshColumnOptions, "where"> {
|
||||
/** Only retry failures with this exception class. */
|
||||
errorType?: string;
|
||||
/** Only retry current failures recorded by this job. */
|
||||
jobId?: string;
|
||||
/** Explicitly release and retry matching quarantined failures. */
|
||||
includeQuarantined?: boolean;
|
||||
/** Upgrade to this immutable Function version while retrying failures. */
|
||||
functionVersion?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Which existing values to recompute during a Function version upgrade.
|
||||
* `"failed"` selects current failures. `"all"` refreshes every eligible live
|
||||
* row. `"none"` preserves existing values and only changes the binding.
|
||||
*/
|
||||
export type FunctionRecompute = "failed" | "all" | "none";
|
||||
|
||||
/** Options for assigning a new immutable Function version to a column. */
|
||||
export interface UpgradeColumnOptions
|
||||
extends Omit<RefreshColumnOptions, "where"> {
|
||||
/** An existing immutable version of the bound Function. */
|
||||
version: string;
|
||||
/** Defaults to `"all"`. Quarantined failures are excluded. */
|
||||
recompute?: FunctionRecompute;
|
||||
}
|
||||
|
||||
/** The terminal outcome of a Function retry or upgrade job. */
|
||||
export interface RefreshColumnJobResult {
|
||||
/** Logical rows successfully assigned a value. */
|
||||
rowsAssigned: bigint;
|
||||
/** Logical rows whose computation failed. */
|
||||
rowsFailed: bigint;
|
||||
/** Logical rows still needing a value, excluding rows counted in `rowsFailed`. */
|
||||
rowsRemaining: bigint;
|
||||
/** The exact table version read by the job. */
|
||||
sourceVersion: bigint;
|
||||
/** The table version made visible by the job, if it published one. */
|
||||
publishedVersion?: bigint;
|
||||
/** Grouped causes reported by the completed job. */
|
||||
errorGroups: FunctionErrorGroup[];
|
||||
/** Whether the reported cause counts omit any failures. */
|
||||
errorGroupsTruncated: boolean;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function decodeRefreshColumnJobResult(
|
||||
value: unknown,
|
||||
): RefreshColumnJobResult {
|
||||
// The Rust typed job validates the terminal result and preserves u64 values.
|
||||
const result = value as {
|
||||
["rows_assigned"]: number | bigint;
|
||||
["rows_failed"]: number | bigint;
|
||||
["rows_remaining"]: number | bigint;
|
||||
["source_version"]: number | bigint;
|
||||
["published_version"]?: number | bigint;
|
||||
["error_groups"]?: {
|
||||
column: string;
|
||||
["error_type"]: string;
|
||||
["error_message"]: string;
|
||||
["rows_failed"]: number | bigint;
|
||||
}[];
|
||||
["error_groups_truncated"]?: boolean;
|
||||
};
|
||||
return {
|
||||
rowsAssigned: BigInt(result.rows_assigned),
|
||||
rowsFailed: BigInt(result.rows_failed),
|
||||
rowsRemaining: BigInt(result.rows_remaining),
|
||||
sourceVersion: BigInt(result.source_version),
|
||||
publishedVersion:
|
||||
result.published_version === undefined
|
||||
? undefined
|
||||
: BigInt(result.published_version),
|
||||
errorGroups: (result.error_groups ?? []).map((group) => ({
|
||||
column: group.column,
|
||||
errorType: group.error_type,
|
||||
errorMessage: group.error_message,
|
||||
rowsFailed: BigInt(group.rows_failed),
|
||||
})),
|
||||
errorGroupsTruncated: result.error_groups_truncated ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
/** A failed Function-column row and its source data at the table's read snapshot. */
|
||||
export interface FunctionFailedRow {
|
||||
/** Values of the requested source columns. */
|
||||
input: Record<string, unknown>;
|
||||
/** The failure for this row and Function column. */
|
||||
error: FunctionErrorRecord;
|
||||
}
|
||||
|
||||
/** Filters and projection for current failing inputs. */
|
||||
export interface FunctionErrorRowsOptions
|
||||
extends Pick<FunctionErrorsOptions, "column" | "jobId" | "limit"> {
|
||||
/** Source columns to return. Defaults to all source columns. */
|
||||
columns?: string[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export async function readFailedRows(
|
||||
table: Table,
|
||||
errors: FunctionErrors,
|
||||
columns?: string[],
|
||||
): Promise<FunctionFailedRow[]> {
|
||||
if ((errors.workflowVersion ?? 0) < 1) {
|
||||
throw new Error(
|
||||
"The server does not support the Function row-failure workflow",
|
||||
);
|
||||
}
|
||||
if (
|
||||
errors.truncated ||
|
||||
errors.fragments.length > 0 ||
|
||||
errors.records.some(
|
||||
(record) => record.rowOffset == null && record.input == null,
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
"Function errors are incomplete; narrow the request or raise limit",
|
||||
);
|
||||
}
|
||||
const { records } = errors;
|
||||
if (records.length === 0) return [];
|
||||
|
||||
const stableIds = new Set<bigint>();
|
||||
const addresses = new Set<bigint>();
|
||||
const keys = records.map((record) => {
|
||||
if (record.input != null) {
|
||||
throw new Error(
|
||||
"Inspect the input source identities for a materialized-view Function error",
|
||||
);
|
||||
}
|
||||
if (typeof record.rowId === "bigint") {
|
||||
stableIds.add(record.rowId);
|
||||
return `_rowid:${record.rowId}`;
|
||||
}
|
||||
if (typeof record.rowAddress === "bigint") {
|
||||
addresses.add(record.rowAddress);
|
||||
return `_rowaddr:${record.rowAddress}`;
|
||||
}
|
||||
throw new Error("This Function error has no source row identity");
|
||||
});
|
||||
const identities = (
|
||||
[
|
||||
["_rowid", stableIds],
|
||||
["_rowaddr", addresses],
|
||||
] as const
|
||||
).filter(([, values]) => values.size > 0);
|
||||
const identityColumns = identities.map(([column]) => column);
|
||||
const selected =
|
||||
columns ?? (await table.schema()).fields.map((field) => field.name);
|
||||
const projection = [...new Set([...selected, ...identityColumns])];
|
||||
const filter = identities
|
||||
.map(([column, values]) => `${column} IN (${[...values].join(",")})`)
|
||||
.join(" OR ");
|
||||
const source = await table
|
||||
.query()
|
||||
.select(projection)
|
||||
.where(filter)
|
||||
.limit(stableIds.size + addresses.size)
|
||||
.toArrow();
|
||||
const selectedNames = new Set(selected);
|
||||
const inputColumns = source.schema.fields
|
||||
.map((field) => field.name)
|
||||
.filter(
|
||||
(name) =>
|
||||
(name !== "_rowid" && name !== "_rowaddr") || selectedNames.has(name),
|
||||
);
|
||||
const byIdentity = new Map<string, Record<string, unknown>>();
|
||||
for (const row of source) {
|
||||
if (row === null) continue;
|
||||
const input = Object.fromEntries(
|
||||
inputColumns.map((name) => [name, row[name]]),
|
||||
);
|
||||
for (const column of identityColumns) {
|
||||
const identity: unknown = row[column];
|
||||
if (typeof identity === "bigint") {
|
||||
byIdentity.set(`${column}:${identity}`, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
return records.map((error, index) => {
|
||||
const input = byIdentity.get(keys[index]);
|
||||
if (input === undefined) {
|
||||
throw new Error(
|
||||
"Some failed inputs are no longer addressable in this snapshot; refresh the error listing",
|
||||
);
|
||||
}
|
||||
return { input, error };
|
||||
});
|
||||
}
|
||||
@@ -63,8 +63,13 @@ export {
|
||||
RefreshColumnResult,
|
||||
FunctionErrors,
|
||||
FunctionErrorsOptions,
|
||||
FunctionErrorGroup,
|
||||
FunctionErrorRecord,
|
||||
FunctionErrorFragment,
|
||||
FunctionProvenance,
|
||||
FunctionProvenanceOptions,
|
||||
FunctionQuarantineOptions,
|
||||
FunctionValueProvenance,
|
||||
RefreshMaterializedViewResult,
|
||||
AlterColumnsResult,
|
||||
UpdateFieldMetadataResult,
|
||||
@@ -111,6 +116,15 @@ export {
|
||||
RenameTableOptions,
|
||||
} from "./connection";
|
||||
|
||||
export type {
|
||||
FunctionErrorRowsOptions,
|
||||
FunctionFailedRow,
|
||||
FunctionRecompute,
|
||||
RefreshColumnJobResult,
|
||||
RetryFailedOptions,
|
||||
UpgradeColumnOptions,
|
||||
} from "./function_recovery";
|
||||
|
||||
export { JobFailureInfo, JobInfo, Session } from "./native.js";
|
||||
|
||||
export {
|
||||
|
||||
+134
-12
@@ -41,6 +41,15 @@ import {
|
||||
runWithSignal,
|
||||
} from "./blob";
|
||||
import { EmbeddingFunctionConfig, getRegistry } from "./embedding/registry";
|
||||
import {
|
||||
type FunctionErrorRowsOptions,
|
||||
type FunctionFailedRow,
|
||||
type RefreshColumnJobResult,
|
||||
type RetryFailedOptions,
|
||||
type UpgradeColumnOptions,
|
||||
decodeRefreshColumnJobResult,
|
||||
readFailedRows,
|
||||
} from "./function_recovery";
|
||||
import { IndexOptions } from "./indices";
|
||||
import { Job } from "./job";
|
||||
import { validateNonNegativeInteger } from "./materialized_view";
|
||||
@@ -55,6 +64,9 @@ import {
|
||||
DropColumnsResult,
|
||||
FunctionErrors,
|
||||
FunctionErrorsOptions,
|
||||
FunctionProvenance,
|
||||
FunctionProvenanceOptions,
|
||||
FunctionQuarantineOptions,
|
||||
IndexConfig,
|
||||
IndexStatistics,
|
||||
JobFailureInfo,
|
||||
@@ -1001,26 +1013,87 @@ export abstract class Table {
|
||||
): Promise<Job>;
|
||||
|
||||
/**
|
||||
* The per-row errors Function refreshes recorded on this table.
|
||||
* List the per-row errors recorded by Function refreshes on this table.
|
||||
*
|
||||
* On LanceDB Enterprise with workflow version 1 or later, the default
|
||||
* lists current failures. Set `history: true` to include retained attempts
|
||||
* for repaired rows. Older deployments keep their existing default listing.
|
||||
* Reading errors requires table read access because messages can include the
|
||||
* input that failed. `errorGroups` describes the returned records.
|
||||
*
|
||||
* A refresh running under a skip policy records each row it skipped with
|
||||
* the input that failed and the error. This lists those records, newest
|
||||
* job first, plus a summary for any fragment whose per-row detail was
|
||||
* capped. LanceDB Enterprise only; reading errors needs read
|
||||
* access to the table, since a message carries the value that failed.
|
||||
* @param {FunctionErrorsOptions} options Optional filters: `jobId`,
|
||||
* `column`, and `limit` (server default 10000, cap 100000).
|
||||
* @returns {Promise<FunctionErrors>} The records, the capped fragments,
|
||||
* and whether the listing stopped at its limit.
|
||||
* @example
|
||||
* ```ts
|
||||
* const { records, truncated } = await table.functionErrors({ column: "embedding" });
|
||||
* const errors = await table.functionErrors({ column: "embedding" });
|
||||
* console.log(errors.records, errors.errorGroups);
|
||||
* ```
|
||||
*/
|
||||
abstract functionErrors(
|
||||
options?: FunctionErrorsOptions,
|
||||
): Promise<FunctionErrors>;
|
||||
|
||||
/**
|
||||
* Read current failing inputs, one result per error record.
|
||||
* Requires a complete LanceDB Enterprise workflow version 1 listing with
|
||||
* row identities. Throws if a failed row is no longer addressable in the
|
||||
* table's read snapshot. For materialized views, see the source identities
|
||||
* on each error record returned by {@link Table#functionErrors}.
|
||||
*/
|
||||
async functionErrorRows(
|
||||
options?: FunctionErrorRowsOptions,
|
||||
): Promise<FunctionFailedRow[]> {
|
||||
const { columns, column, jobId, limit } = options ?? {};
|
||||
const errors = await this.functionErrors({ column, jobId, limit });
|
||||
return readFailedRows(this, errors, columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a job to retry exactly the current failures of one Function column.
|
||||
* Filters apply on the server. Quarantined rows are excluded by default.
|
||||
* Requires LanceDB Enterprise Function failure workflow version 1 or later.
|
||||
*/
|
||||
async retryFailed(
|
||||
_column: string,
|
||||
_options?: RetryFailedOptions,
|
||||
): Promise<Job<RefreshColumnJobResult>> {
|
||||
throw new Error("retryFailed is not supported on this table type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an upgrade to an existing immutable Function version and choose
|
||||
* which rows to recompute. New and changed inputs use the new version.
|
||||
* Requires LanceDB Enterprise Function failure workflow version 1 or later.
|
||||
*/
|
||||
async upgradeColumn(
|
||||
_column: string,
|
||||
_options: UpgradeColumnOptions,
|
||||
): Promise<Job<RefreshColumnJobResult>> {
|
||||
throw new Error("upgradeColumn is not supported on this table type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Quarantine current failures and return the number of affected rows.
|
||||
* Set `quarantined: false` to release them for future refreshes.
|
||||
* Requires LanceDB Enterprise Function failure workflow version 1 or later.
|
||||
*/
|
||||
async quarantineFailed(
|
||||
_column: string,
|
||||
_options?: FunctionQuarantineOptions,
|
||||
): Promise<number> {
|
||||
throw new Error("quarantineFailed is not supported on this table type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the producing Function version and job for each returned value.
|
||||
* Check `truncated` before treating the result as a complete listing.
|
||||
* Requires LanceDB Enterprise Function failure workflow version 1 or later.
|
||||
*/
|
||||
async functionProvenance(
|
||||
_column: string,
|
||||
_options?: FunctionProvenanceOptions,
|
||||
): Promise<FunctionProvenance> {
|
||||
throw new Error("functionProvenance is not supported on this table type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return exact freshness status for Function-backed output columns.
|
||||
*
|
||||
@@ -2012,7 +2085,56 @@ export class LocalTable extends Table {
|
||||
options?: FunctionErrorsOptions,
|
||||
): Promise<FunctionErrors> {
|
||||
validateNonNegativeInteger(options?.limit, "limit");
|
||||
return await this.inner.functionErrors(options);
|
||||
return this.inner.functionErrors(options);
|
||||
}
|
||||
|
||||
override async retryFailed(
|
||||
column: string,
|
||||
options?: RetryFailedOptions,
|
||||
): Promise<Job<RefreshColumnJobResult>> {
|
||||
const {
|
||||
errorType,
|
||||
jobId,
|
||||
includeQuarantined,
|
||||
functionVersion,
|
||||
...refresh
|
||||
} = options ?? {};
|
||||
const job = await this.inner.refreshColumnAsync(column, refresh, {
|
||||
retryErrors: true,
|
||||
retryErrorType: errorType,
|
||||
retryJobId: jobId,
|
||||
includeQuarantined,
|
||||
functionVersion,
|
||||
recompute: functionVersion === undefined ? undefined : "failed",
|
||||
});
|
||||
return new Job(job, decodeRefreshColumnJobResult);
|
||||
}
|
||||
|
||||
override async upgradeColumn(
|
||||
column: string,
|
||||
options: UpgradeColumnOptions,
|
||||
): Promise<Job<RefreshColumnJobResult>> {
|
||||
const { version, recompute = "all", ...refresh } = options;
|
||||
const job = await this.inner.refreshColumnAsync(column, refresh, {
|
||||
functionVersion: version,
|
||||
recompute,
|
||||
});
|
||||
return new Job(job, decodeRefreshColumnJobResult);
|
||||
}
|
||||
|
||||
override async quarantineFailed(
|
||||
column: string,
|
||||
options?: FunctionQuarantineOptions,
|
||||
): Promise<number> {
|
||||
return this.inner.quarantineFunctionErrors(column, options);
|
||||
}
|
||||
|
||||
override async functionProvenance(
|
||||
column: string,
|
||||
options?: FunctionProvenanceOptions,
|
||||
): Promise<FunctionProvenance> {
|
||||
validateNonNegativeInteger(options?.limit, "limit");
|
||||
return this.inner.functionProvenance(column, options);
|
||||
}
|
||||
|
||||
async functionColumnStatuses(
|
||||
|
||||
+234
-17
@@ -685,14 +685,24 @@ impl Table {
|
||||
&self,
|
||||
column: String,
|
||||
options: Option<RefreshColumnOptions>,
|
||||
recovery: Option<FunctionRecoveryOptions>,
|
||||
) -> napi::Result<crate::job::Job> {
|
||||
let options = options.unwrap_or_default().try_into()?;
|
||||
let mut options: lancedb::table::RefreshColumnOptions =
|
||||
options.unwrap_or_default().try_into()?;
|
||||
let typed_result = recovery.is_some();
|
||||
if let Some(recovery) = recovery {
|
||||
recovery.apply(&mut options)?;
|
||||
}
|
||||
let job = self
|
||||
.inner_ref()?
|
||||
.refresh_column_async_with_options(column, options)
|
||||
.await
|
||||
.default_error()?;
|
||||
Ok(crate::job::Job::new(job))
|
||||
Ok(if typed_result {
|
||||
crate::job::Job::new_typed(job)
|
||||
} else {
|
||||
crate::job::Job::new(job)
|
||||
})
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
@@ -701,18 +711,11 @@ impl Table {
|
||||
options: Option<FunctionErrorsOptions>,
|
||||
) -> napi::Result<FunctionErrors> {
|
||||
let options = options.unwrap_or_default();
|
||||
let limit = options
|
||||
.limit
|
||||
.map(|limit| {
|
||||
usize::try_from(limit)
|
||||
.map_err(|_| napi::Error::from_reason("limit must be a non-negative integer"))
|
||||
})
|
||||
.transpose()?;
|
||||
let request = lancedb::function::FunctionErrorsRequest {
|
||||
history: false,
|
||||
history: options.history.unwrap_or_default(),
|
||||
job_id: options.job_id,
|
||||
column: options.column,
|
||||
limit,
|
||||
limit: function_listing_limit(options.limit)?,
|
||||
page_token: options.page_token,
|
||||
};
|
||||
let errors = self
|
||||
@@ -723,6 +726,62 @@ impl Table {
|
||||
Ok(errors.into())
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn quarantine_function_errors(
|
||||
&self,
|
||||
column: String,
|
||||
options: Option<FunctionQuarantineOptions>,
|
||||
) -> napi::Result<f64> {
|
||||
let options = options.unwrap_or_default();
|
||||
let options = lancedb::function::FunctionQuarantineOptions {
|
||||
quarantined: options.quarantined.unwrap_or(true),
|
||||
job_id: options.job_id,
|
||||
error_type: options.error_type,
|
||||
after_attempts: positive_u32(options.after_attempts, "afterAttempts")?,
|
||||
};
|
||||
let affected = self
|
||||
.inner_ref()?
|
||||
.quarantine_function_errors(&column, options)
|
||||
.await
|
||||
.default_error()?;
|
||||
Ok(affected as f64)
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn function_provenance(
|
||||
&self,
|
||||
column: String,
|
||||
options: Option<FunctionProvenanceOptions>,
|
||||
) -> napi::Result<FunctionProvenance> {
|
||||
let options = options.unwrap_or_default();
|
||||
let version = match options.version {
|
||||
None => None,
|
||||
Some(Either::A(number)) => Some(positive_safe_integer(number, "version")?),
|
||||
Some(Either::B(bigint)) => {
|
||||
let (negative, value, lossless) = bigint.get_u64();
|
||||
if negative || !lossless || value == 0 {
|
||||
return Err(napi::Error::from_reason(
|
||||
"version must be a positive lossless u64 bigint",
|
||||
));
|
||||
}
|
||||
Some(value)
|
||||
}
|
||||
};
|
||||
let options = lancedb::function::FunctionProvenanceOptions {
|
||||
version,
|
||||
limit: function_listing_limit(options.limit)?,
|
||||
};
|
||||
let provenance = self
|
||||
.inner_ref()?
|
||||
.function_provenance(&column, options)
|
||||
.await
|
||||
.default_error()?;
|
||||
Ok(FunctionProvenance {
|
||||
records: provenance.records.into_iter().map(Into::into).collect(),
|
||||
truncated: provenance.truncated,
|
||||
})
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn function_column_statuses(
|
||||
&self,
|
||||
@@ -1946,10 +2005,78 @@ pub struct FunctionErrorsOptions {
|
||||
pub column: Option<String>,
|
||||
/// At most this many records (server default 10000, cap 100000).
|
||||
pub limit: Option<i64>,
|
||||
/// Include retained historical attempts, including repaired rows. Requires workflow version 1 or later.
|
||||
pub history: Option<bool>,
|
||||
/// Empty starts retained history, including repaired rows, for an exact jobId; otherwise continue that page.
|
||||
pub page_token: Option<String>,
|
||||
}
|
||||
|
||||
fn function_listing_limit(limit: Option<i64>) -> napi::Result<Option<usize>> {
|
||||
limit
|
||||
.map(|limit| {
|
||||
usize::try_from(limit)
|
||||
.map_err(|_| napi::Error::from_reason("limit must be a non-negative integer"))
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
/// Select current failures to quarantine or release.
|
||||
#[napi(object)]
|
||||
#[derive(Default)]
|
||||
pub struct FunctionQuarantineOptions {
|
||||
/// Quarantine by default. Set false to release failures for later refreshes.
|
||||
pub quarantined: Option<bool>,
|
||||
/// Only failures recorded by this job.
|
||||
pub job_id: Option<String>,
|
||||
/// Only failures with this exception class.
|
||||
pub error_type: Option<String>,
|
||||
/// Only failures with at least this many attempts. Defaults to 1.
|
||||
pub after_attempts: Option<f64>,
|
||||
}
|
||||
|
||||
/// Snapshot and record limit for a producing-version listing.
|
||||
#[napi(object)]
|
||||
#[derive(Default)]
|
||||
pub struct FunctionProvenanceOptions {
|
||||
/// An exact table version. Defaults to the table handle's read version.
|
||||
pub version: Option<Either<f64, BigInt>>,
|
||||
/// Maximum records to return (server default 10000, cap 100000).
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct FunctionRecoveryOptions {
|
||||
pub retry_errors: Option<bool>,
|
||||
pub retry_job_id: Option<String>,
|
||||
pub retry_error_type: Option<String>,
|
||||
pub include_quarantined: Option<bool>,
|
||||
pub function_version: Option<String>,
|
||||
pub recompute: Option<String>,
|
||||
}
|
||||
|
||||
impl FunctionRecoveryOptions {
|
||||
fn apply(self, options: &mut lancedb::table::RefreshColumnOptions) -> napi::Result<()> {
|
||||
use lancedb::function::FunctionRecompute;
|
||||
options.retry_errors = self.retry_errors;
|
||||
options.retry_job_id = self.retry_job_id;
|
||||
options.retry_error_type = self.retry_error_type;
|
||||
options.include_quarantined = self.include_quarantined;
|
||||
options.function_version = self.function_version;
|
||||
options.recompute = match self.recompute.as_deref() {
|
||||
None => None,
|
||||
Some("failed") => Some(FunctionRecompute::Failed),
|
||||
Some("all") => Some(FunctionRecompute::All),
|
||||
Some("none") => Some(FunctionRecompute::None),
|
||||
Some(_) => {
|
||||
return Err(napi::Error::from_reason(
|
||||
"recompute must be 'failed', 'all', or 'none'",
|
||||
));
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// CPU, memory, and ephemeral-storage limits for one Function refresh
|
||||
/// control-plane pod.
|
||||
#[napi(object)]
|
||||
@@ -2063,8 +2190,8 @@ pub struct RefreshColumnOptions {
|
||||
pub total_gpu_count: Option<f64>,
|
||||
/// Override retries of failed user-code calls for this refresh.
|
||||
pub retry_policy: Option<FunctionRetryPolicy>,
|
||||
/// `"fail"` (default) stops on a row error; `"skip"` writes null and
|
||||
/// records the error, subject to the failure limits.
|
||||
/// `"fail"` stops on a row error; `"skip"` records it and continues,
|
||||
/// subject to the failure limits. The default is server-dependent.
|
||||
pub error_policy: Option<String>,
|
||||
/// Under a skip policy, fail the job once more than this share of rows
|
||||
/// (0 to 1) has failed.
|
||||
@@ -2234,35 +2361,113 @@ pub struct FunctionErrorRecord {
|
||||
/// The row's offset within the fragment; absent when the fragment's
|
||||
/// detail was capped.
|
||||
pub row_offset: Option<i64>,
|
||||
/// Stable row identity when recorded. It survives compaction and rewrite.
|
||||
pub row_id: Option<BigInt>,
|
||||
/// Physical row address at the recorded version. A rewrite can change it.
|
||||
pub row_address: Option<BigInt>,
|
||||
pub column: String,
|
||||
pub function: String,
|
||||
pub function_version: String,
|
||||
pub table_version: i64,
|
||||
pub error_type: String,
|
||||
pub error_message: String,
|
||||
/// Number of failed invocation attempts, when recorded.
|
||||
pub attempts: Option<u32>,
|
||||
/// User-code traceback, possibly truncated by the server.
|
||||
pub traceback: Option<String>,
|
||||
pub created_at_millis: i64,
|
||||
/// First failure time for this row, when recorded.
|
||||
pub first_seen_at_millis: Option<i64>,
|
||||
/// Latest failure time for this row, when recorded.
|
||||
pub last_seen_at_millis: Option<i64>,
|
||||
/// Whether the failure is quarantined. Absent on older listings.
|
||||
pub quarantined: Option<bool>,
|
||||
/// Source identities for a materialized-view Function invocation.
|
||||
#[napi(ts_type = "unknown")]
|
||||
pub input: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
impl From<lancedb::function::FunctionErrorRecord> for FunctionErrorRecord {
|
||||
fn from(record: lancedb::function::FunctionErrorRecord) -> Self {
|
||||
impl FunctionErrorRecord {
|
||||
fn from_record(record: lancedb::function::FunctionErrorRecord, has_workflow: bool) -> Self {
|
||||
Self {
|
||||
job_id: record.job_id,
|
||||
fragment_id: record.fragment_id as i64,
|
||||
row_offset: record.row_offset.map(i64::from),
|
||||
row_id: record.row_id.map(BigInt::from),
|
||||
row_address: record.row_address.map(BigInt::from),
|
||||
column: record.column,
|
||||
function: record.function,
|
||||
function_version: record.function_version,
|
||||
table_version: record.table_version as i64,
|
||||
error_type: record.error_type,
|
||||
error_message: record.error_message,
|
||||
attempts: record.attempts,
|
||||
traceback: record.traceback,
|
||||
created_at_millis: record.created_at_millis,
|
||||
first_seen_at_millis: record.first_seen_at_millis,
|
||||
last_seen_at_millis: record.last_seen_at_millis,
|
||||
quarantined: has_workflow.then_some(record.quarantined),
|
||||
input: record.input,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One cause among the returned Function errors.
|
||||
#[napi(object)]
|
||||
pub struct FunctionErrorGroup {
|
||||
pub column: String,
|
||||
pub error_type: String,
|
||||
pub error_message: String,
|
||||
pub rows_failed: BigInt,
|
||||
}
|
||||
|
||||
impl From<lancedb::function::FunctionErrorGroup> for FunctionErrorGroup {
|
||||
fn from(group: lancedb::function::FunctionErrorGroup) -> Self {
|
||||
Self {
|
||||
column: group.column,
|
||||
error_type: group.error_type,
|
||||
error_message: group.error_message,
|
||||
rows_failed: BigInt::from(group.rows_failed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The Function and job that produced one stored value.
|
||||
#[napi(object)]
|
||||
pub struct FunctionValueProvenance {
|
||||
pub column: String,
|
||||
pub job_id: String,
|
||||
pub function_name: String,
|
||||
pub function_version: String,
|
||||
pub row_id: Option<BigInt>,
|
||||
pub row_address: Option<BigInt>,
|
||||
pub source_version: BigInt,
|
||||
pub published_version: BigInt,
|
||||
}
|
||||
|
||||
impl From<lancedb::function::FunctionValueProvenance> for FunctionValueProvenance {
|
||||
fn from(record: lancedb::function::FunctionValueProvenance) -> Self {
|
||||
Self {
|
||||
column: record.column,
|
||||
job_id: record.job_id,
|
||||
function_name: record.function_name,
|
||||
function_version: record.function_version,
|
||||
row_id: record.row_id.map(BigInt::from),
|
||||
row_address: record.row_address.map(BigInt::from),
|
||||
source_version: BigInt::from(record.source_version),
|
||||
published_version: BigInt::from(record.published_version),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A bounded producing-version listing for a table snapshot.
|
||||
#[napi(object)]
|
||||
pub struct FunctionProvenance {
|
||||
pub records: Vec<FunctionValueProvenance>,
|
||||
/// Whether the listing stopped at its limit.
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
||||
/// A fragment whose per-row error detail was capped: `rowsSkipped` rows
|
||||
/// failed, of which only `rowsRecorded` have a record of their own.
|
||||
#[napi(object)]
|
||||
@@ -2287,8 +2492,12 @@ impl From<lancedb::function::FunctionErrorFragment> for FunctionErrorFragment {
|
||||
|
||||
/// A table's per-row Function errors.
|
||||
#[napi(object)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FunctionErrors {
|
||||
/// Version of the Enterprise row-failure workflow, if advertised by the server.
|
||||
pub workflow_version: Option<u16>,
|
||||
/// Grouped causes over the returned records, if the server supports the workflow.
|
||||
/// Counts can be incomplete. Check `truncated` and `fragments` before using them as totals.
|
||||
pub error_groups: Option<Vec<FunctionErrorGroup>>,
|
||||
/// The recorded rows, newest job first.
|
||||
pub records: Vec<FunctionErrorRecord>,
|
||||
/// Fragments whose detail was capped.
|
||||
@@ -2411,8 +2620,16 @@ impl From<lancedb::table::FunctionColumnStatus> for FunctionColumnStatus {
|
||||
|
||||
impl From<lancedb::function::FunctionErrors> for FunctionErrors {
|
||||
fn from(errors: lancedb::function::FunctionErrors) -> Self {
|
||||
let has_workflow = errors.workflow_version.is_some_and(|version| version >= 1);
|
||||
Self {
|
||||
records: errors.records.into_iter().map(Into::into).collect(),
|
||||
workflow_version: errors.workflow_version,
|
||||
error_groups: has_workflow
|
||||
.then(|| errors.error_groups.into_iter().map(Into::into).collect()),
|
||||
records: errors
|
||||
.records
|
||||
.into_iter()
|
||||
.map(|record| FunctionErrorRecord::from_record(record, has_workflow))
|
||||
.collect(),
|
||||
fragments: errors.fragments.into_iter().map(Into::into).collect(),
|
||||
truncated: errors.truncated,
|
||||
page_token: errors.page_token,
|
||||
|
||||
Reference in New Issue
Block a user