Remote data prewarm used REST even though SQL supported filters and concurrency, and both maintenance APIs returned after acceptance without exposing a consistent typed completion handle. Compaction's legacy statistics therefore could not describe the work committed by its durable job. This PR adds job-returning compaction and data-prewarm methods across Rust, Python sync/async and TypeScript, and moves data-prewarm submission to SQL. Legacy methods retain return-after-acceptance behavior; data prewarm now requires a compatible SQL PREWARM server and Flight SQL connectivity. This consolidates #5037, #5055 and #4906. This was accomplished with the following changes: - Added `compact_async()` / `compactAsync()` and `prewarm_data_async()` / `prewarmDataAsync()`, retaining the command receipt's durable job ID. - Added `PrewarmDataOptions` for columns, a metadata-pruning filter and concurrency; both operations inherit database, namespace and branch from the table handle. - Added filter/concurrency arguments to legacy Python `prewarm_data()` and a TypeScript `prewarmData(options)` overload, preserving the columns-array form and discarding the handle after acceptance. - Added typed `CompactionResult` and `PrewarmDataResult` decoding, including reopened jobs; missing result payloads fail explicitly and omitted measurements remain unknown. - Reused the shared Job lifecycle for status, refresh, progress callbacks, cancellation and events; Python maintenance progress bars display rewritten rows or completed executors. - Added TypeScript `wait({ timeoutMs, onProgress })` and Rust `wait_with_options(JobWaitOptions)`, complementing Python's existing timeout argument without cancelling the durable job. - Validated single unambiguous receipts, preserved compaction option presence/default inheritance, and returned actionable unsupported-server errors without dropping options or falling back to REST. - Updated native bindings, API references and maintenance documentation with job methods, result semantics, tuning and compatibility requirements. ### Usage and behaviour **New** = added here; **Enhanced** = existing support extended; **Existing** = already on main. This table describes remote SDK behavior; server-side SQL/CLI capabilities are prerequisites, not additions made by this SDK PR. | Surface | Capability | Compact | Data prewarm | Assessment | | --- | --- | --- | --- | --- | | Rust / Python sync+async / TypeScript | Submission transport | Existing SQL OPTIMIZE | **New:** REST → SQL PREWARM | Both now submit through SQL | | All SDKs | Durable job-returning API | **New:** `compact_async` / `compactAsync` | **New:** `prewarm_data_async` / `prewarmDataAsync` | Same lifecycle model | | All SDKs | Options and target scope | **New handle:** four existing compaction overrides, with omitted fields inherited | **New options:** columns/filter/concurrency | Namespace and branch preserved for both | | Python / TypeScript | Legacy convenience calls | Existing optimize acceptance behavior preserved | **Enhanced:** legacy methods accept filter/concurrency and use SQL | Return after acceptance; no completion wait | | All SDKs | Typed successful result | **New:** committed rows, file/fragment changes, partial commit and `more_work` | **New:** pinned version, fragments and executor outcomes | Different measurements are intentional | | All SDKs | Status / refresh / progress | Existing Job APIs reused by **new** maintenance handle | Existing Job APIs reused by **new** maintenance handle | HTTP monitoring remains | | Python / TypeScript | Progress presentation | **Enhanced:** rewrite rows/groups | **Enhanced:** executor progress | Shared callbacks; Python bars use operation counters | | All SDKs | Bounded wait | Python existing; **new** TS/Rust timeout controls | Same shared timeout support | Timeout stops this wait; job continues | | All SDKs | Reopen and await typed outcome | **New:** compaction result decoding on reopened handle | **New:** prewarm result decoding on reopened handle | Rust selects the typed result explicitly | | All SDKs | Cancel / events | Existing shared APIs available on **new** handle | Same | HTTP underneath; permissions unchanged | | All SDKs | Typed preview helper | Unavailable | Unavailable | General SQL where exposed; no helper added | | Authorization | Submission | Existing table Ownership plus parent Usage | SQL path uses Select plus parent Usage | Intentional difference | | All SDKs | Local / historical handles | New durable API rejects them | New durable API rejects them | Remote current-branch jobs only | ```python from datetime import timedelta # Legacy convenience call: returns None after acceptance. table.prewarm_data(["payload"], filter="id >= 1000", concurrency=4) warm = table.prewarm_data_async(["payload"], filter="id >= 1000", concurrency=4) warmed = warm.wait(timeout=timedelta(minutes=10), progress=print) print(warmed.table_version, warmed.executors_completed) compact = table.compact_async(compaction_options={"max_source_rows": 1000000}) committed = compact.wait(timeout=timedelta(minutes=10), progress=print) print(committed.rows_succeeded, committed.fragments_removed, committed.more_work) reopened_result = db.open_job(compact.id).wait() ``` ```typescript await table.prewarmData({ columns: ["payload"], filter: "id >= 1000", concurrency: 4 }); const job = await table.prewarmDataAsync({ columns: ["payload"], filter: "id >= 1000", concurrency: 4, }); const result = await job.wait({ timeoutMs: 600_000, onProgress: console.log }); ``` ```rust use std::time::Duration; use lancedb::job::JobWaitOptions; let job = table.compact_async(Default::default()).await?; let result = job.wait_with_options( JobWaitOptions::new().timeout(Duration::from_secs(600)), ).await?; ``` Python async tables await both submission and Job methods. Rust's legacy `prewarm_data(columns)` keeps its columns-only signature; use `PrewarmDataOptions` on the new job-returning method for filtering/concurrency. Wait deadlines cover pending status requests and polling delays. Existing `wait()`, TypeScript `wait(callback)` and Rust `wait_with_progress(callback)` remain supported. Status/progress/refresh/cancel/events still use generic HTTP job APIs; those endpoints and their read/event/cancel permissions must remain available. Cancelling or timing out does not roll back committed work. Compaction results describe committed rewrites and include deletion files in file counts. Prewarm results describe work against a pinned snapshot, with partial executors included in completed executors; nonempty byte/range measurements remain unknown. Missing results require compatible server/worker support rather than placeholder zero statistics. Filtering uses conservative metadata pruning, not an exact row-filter scan. ### Testing Six checked-in live Python sync/async cases pass against matching server/worker builds for compaction, job-returning prewarm and legacy filtered submission. Ten additional live Node scenarios pass for legacy/default/options forms, filters/concurrency, empty plans, validation, persisted specifications and readback. Targeted regressions pass: Python remote maintenance (80), shared jobs (82), local prewarm rejection (4); Node remote (107) and prewarm API cases (28), plus the previously exercised Rust remote regressions. Tests cover receipt parsing, typed results, reopening, unknown measurements, timeouts, and legacy calls returning None/undefined without polling. Dependency pins are unchanged. Azure account-hint acknowledgment was verified locally with filesystem storage; real Azure-backed storage still needs deployment-specific validation.
5.4 KiB
@lancedb/lancedb • Docs
@lancedb/lancedb / Job
Class: Job<T>
A handle to an operation that may still be running.
The operation may already be complete when the handle is created.
The detail getters read what the handle last observed. Submitting an operation returns only a job id, so populating them eagerly would cost an extra round trip on every call:
- Job.refresh and Job.status fetch the whole record.
- Job.wait records the terminal state it establishes, but not the rest of the record.
- Registry details are null until one of those runs. Query handles report jobType "query" immediately.
Type Parameters
• T = void
Accessors
creationMs
get creationMs(): null | number
When the job was created, in milliseconds since the epoch.
Returns
null | number
failure
get failure(): null | JobFailureInfo
Why the job failed, when it failed and the server reports a reason.
Returns
null | JobFailureInfo
id
get id(): null | string
Identifies the operation on the server that is running it.
Registry handles expose a registry job ID; query handles expose a connection-scoped SQL query UUID string. Local handles have no ID. Query handles report jobType "query". Their IDs are not registry IDs or durable resume tokens.
Returns
null | string
jobType
get jobType(): null | string
"query" immediately for SQL-backed handles; otherwise the cached server-reported job type. Null for in-process handles.
Returns
null | string
result
get result(): any
The job-type-specific terminal result. Null until the job succeeds, so a job that never terminates reports its progress through Job.events instead.
Returns
any
spec
get spec(): any
The job-type-specific specification it was submitted with.
Returns
any
state
get state(): null | string
The last observed lifecycle state, without contacting the backend.
Returns
null | string
Methods
cancel()
cancel(): Promise<void>
Request cancellation. Cancelling a finished operation is a no-op.
Returns
Promise<void>
events()
events(options?): Promise<Table<any>>
This job's recorded lifecycle events.
Where the getters above report a terminal result only once the job reaches
one, events are written as the job runs and outlive the workers that
produced them. A distributed job records a claim/claim_complete pair
per unit of work, each carrying rows_processed, so a job that never
finishes still accounts for what it did.
The server caps results at 1000 rows by default and 10,000 at most, and
truncates without saying so, so pass limit for a job that emits an event
per fragment. filter is a SQL-like expression over the state,
updated_by, emitted_from, emitted_by, and claim_entity columns.
Parameters
- options?:
JobEventsOptions
Returns
Promise<Table<any>>
progress()
progress(): Promise<null | JobProgress>
Fetch a structured progress snapshot.
Registry jobs include lifecycle and queue metadata even when their job type does not report counters. The returned object is forward-compatible with newer servers and job types. In-process operations return null.
Returns
Promise<null | JobProgress>
refresh()
refresh(): Promise<void>
Ask the backend for this job's current state, and for a server-side job its full record, then cache it for the getters above.
Returns
Promise<void>
status()
status(): Promise<string>
The operation's current lifecycle state: "running", "finished", "failed", or "cancelled".
A point snapshot; unlike Job.wait it does not block or reject on a terminal failure state. Also refreshes the getters above.
Returns
Promise<string>
toString()
toString(): string
Every field the handle currently knows, one per line, with the JSON payloads indented -- a refresh job's spec and result are the point of printing it.
Returns
string
wait()
wait(optionsOrProgress?): Promise<T>
Wait until the operation reaches a terminal state.
The optional callback observes the same snapshots fetched by the backend
poller that drives completion; it does not start another poller. Without a
callback, this preserves the original wait behavior. The callback is a
synchronous observer: its return value is ignored and not awaited. If it
throws, the error is logged with console.warn and waiting continues; a
callback exception does not reject wait.
Pass an options object to set a client-side timeout. Expiry rejects with an
error and stops this wait, including pending status requests and backoff.
The operation continues; use the same handle to wait again. Registry jobs
can also be reopened with Connection.openJob; query IDs cannot.
Parameters
- optionsOrProgress?:
JobWaitOptions|JobProgressCallback
Returns
Promise<T>
Example
const result = await job.wait({ timeoutMs: 60_000, onProgress: console.log });