mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
LanceDB SDKs can submit data prewarm jobs, but callers have to issue SQL directly to inspect a plan before warming. The existing text response does not provide a typed pruning contract. This adds metadata-only preview helpers across Rust, Python sync/async, and TypeScript, using a compatible Enterprise server’s structured SQL response. This was accomplished with the following changes: - Add `explain_prewarm_data(PrewarmDataOptions)`, Python `explain_prewarm_data(...)`, and TypeScript `explainPrewarmData(options)`. - Expose `PrewarmDataPlan` and `PrewarmPruningSummary`, preserving zero versus unknown counts and future pruning-mode strings. - Reuse submission options, identifier/filter validation, namespace and branch context, and Azure source-account hint handling. - Validate the versioned JSON response without parsing display text, submitting a warming job, polling HTTP job APIs, or falling back to REST. - Add API documentation, Flight SQL transport tests, Python sync/async response tests, and an opt-in live-service integration test. ### Usage and behaviour ```python plan = table.explain_prewarm_data(["payload"], filter="quality > 0.7") print(plan.table_version, plan.pruning.selected_fragments) ``` The helper returns a plan directly. It requires table Select plus database/namespace Usage and a server supporting `EXPLAIN (FORMAT JSON) PREWARM`. It reads metadata without creating a warming job. Selected ranges are conservative physical candidates; unknown counts remain `None`/`null`. A later submission resolves and plans its own snapshot. Historical-version and Embedded table handles are unsupported.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
import { decodePrewarmDataPlan } from "../lancedb/prewarm";
|
|
import { Table } from "../lancedb/table";
|
|
|
|
test.each([null, 0, 2])(
|
|
"preview preserves unknown and zero range counts: %s",
|
|
(ranges) => {
|
|
const plan = decodePrewarmDataPlan(
|
|
JSON.parse(`{
|
|
"table_version":42,"plan":"display text",
|
|
"pruning":{"mode":"future_mode","input_fragments":3,"selected_fragments":0,
|
|
"pruned_fragments":3,"selected_row_ranges":${ranges}}
|
|
}`),
|
|
);
|
|
expect(plan.tableVersion).toBe(42);
|
|
expect(plan.pruning.mode).toBe("future_mode");
|
|
expect(plan.pruning.selectedRowRanges).toBe(ranges);
|
|
expect(plan.pruning.fallbackReason).toBeNull();
|
|
},
|
|
);
|
|
|
|
test("custom tables inherit an unsupported preview default", async () => {
|
|
// Only the inherited default is exercised; unrelated abstract operations
|
|
// do not need implementations in this fixture.
|
|
const table = Object.create(Table.prototype) as Table;
|
|
await expect(
|
|
table.explainPrewarmData({ columns: ["payload"], filter: "id > 0" }),
|
|
).rejects.toThrow(
|
|
"data prewarm previews are not supported by this table implementation",
|
|
);
|
|
});
|