mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
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.
189 lines
6.4 KiB
Plaintext
189 lines
6.4 KiB
Plaintext
---
|
|
title: "Job"
|
|
sidebarTitle: "Job"
|
|
description: "SHOW JOBS, SHOW JOB EVENTS, DESCRIBE JOB, SHOW ERRORS, and controlling a running job with PAUSE, RESUME and CANCEL."
|
|
icon: hourglass-half
|
|
keywords: ["show jobs", "show job events", "describe job", "show errors", "pause job", "resume job", "cancel job", "sql"]
|
|
availability:
|
|
embedded: unavailable
|
|
enterprise: available
|
|
---
|
|
|
|
A [job](/basics/jobs) is not a catalog object (it has no schema and is not
|
|
namespaced), but it has its own SQL statements, grouped here the same way
|
|
the catalog objects are.
|
|
|
|
## SHOW JOBS {#show}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SHOW JOBS
|
|
SHOW JOBS FOR TABLE documents
|
|
SHOW JOBS FOR JOB '<parent_job_id>' [LIMIT n]
|
|
```
|
|
</CodeGroup>
|
|
|
|
The unfiltered command lists jobs in the connected database, newest first:
|
|
id, type, state, creation time -- the SQL counterpart of `list_jobs`. `FOR
|
|
TABLE` filters that listing by the current namespace's table name. `FOR JOB`
|
|
lists the parent's direct child jobs using the REST API's child model.
|
|
Child rows expose their ID, kind, phase, row progress and attempt; unknown
|
|
values remain NULL. Children are read-only diagnostic identities.
|
|
|
|
`FOR JOB` defaults to 1,000 children and accepts `LIMIT` from 1 to 10,000,
|
|
following backend continuation pages up to that limit. Child history can be
|
|
`available`, `not_yet_recorded`, or `unavailable` after archival.
|
|
|
|
<Note>
|
|
A job you completed weeks ago eventually stops appearing here -- it was
|
|
archived, not deleted. Two deployment-scheduled jobs sweep the registry on a
|
|
per-database schedule: `job_registry_archive` moves terminal jobs out of the
|
|
active registry into archival storage, and `job_events_export` separately
|
|
copies terminal jobs' event histories into a curated system table for
|
|
metering, where the deployment enables it. A job's events can survive in
|
|
that exported table after the job itself is archived.
|
|
</Note>
|
|
|
|
## SHOW JOB EVENTS {#events}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SHOW JOB EVENTS '<parent_or_child_job_id>' [LIMIT n]
|
|
```
|
|
</CodeGroup>
|
|
|
|
Events are returned newest first. Parent history does not include child
|
|
history. The default limit is 1,000; valid limits range from 1 to 10,000.
|
|
The result includes event sequence, state, timestamps, origin, claim and
|
|
resource/work fields. Child `kind` and `details` expose the REST API's
|
|
allowlisted diagnostics; raw parent payloads are excluded.
|
|
|
|
## DESCRIBE JOB {#describe}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
DESCRIBE JOB '<job_id>' [FORMAT TEXT | TABLE | JSON]
|
|
DESC JOB '<job_id>' [FORMAT TEXT | TABLE | JSON]
|
|
```
|
|
</CodeGroup>
|
|
|
|
`TEXT` is the default and shows a finished root job's timing profile;
|
|
`TABLE` returns typed phase/step rows. These formats have no profile rows
|
|
while a job runs.
|
|
|
|
On compatible deployments, `JSON` returns one document in the `profile`
|
|
column with `job_id`, `job_type`, `job_state`, reported `progress`, and the
|
|
successful operation's `result`, alongside any timing profile. It works
|
|
while the job runs, when `result` is null. Compaction counters describe
|
|
committed work only in the result; progress counters describe observed
|
|
execution work. Data prewarm results identify the pinned table version and
|
|
reported executor work. Unavailable measurements remain absent or null.
|
|
|
|
```sql
|
|
DESCRIBE JOB '<job_id>' FORMAT JSON;
|
|
```
|
|
|
|
Older deployments return only the timing profile.
|
|
|
|
## SHOW ERRORS {#errors}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SHOW ERRORS ON <table> [FOR JOB '<job-id>'] [LIMIT <n>]
|
|
```
|
|
</CodeGroup>
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SHOW ERRORS ON documents
|
|
SHOW ERRORS ON documents FOR JOB 'job-abc' LIMIT 100
|
|
```
|
|
</CodeGroup>
|
|
|
|
Why rows failed. Reach for this when a [refresh](/sql/dml/refresh-column) reports
|
|
fewer filled rows than you expected.
|
|
|
|
### Errors and limits {#errors-and-limits}
|
|
|
|
| | |
|
|
| --- | --- |
|
|
| `LIMIT` | defaults to 10,000; must be between 1 and 100,000 |
|
|
| Failed jobs scanned without `FOR JOB` | 32 most recent |
|
|
| Tables the server does not open directly | not supported |
|
|
|
|
Without `FOR JOB` this surveys recent failures and stops at 32 jobs. When the
|
|
listing stops at your `LIMIT`, the message says so. Narrow with `FOR JOB`
|
|
rather than raising the limit blindly.
|
|
|
|
<Note>
|
|
`SHOW JOBS`, `SHOW JOB EVENTS`, `DESCRIBE JOB` and `SHOW ERRORS` require
|
|
system `USAGE`, as do the equivalent REST diagnostics. Explicit table
|
|
listings additionally use the table-list authorization policy.
|
|
</Note>
|
|
|
|
## PAUSE JOB {#pause}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
PAUSE JOB 'j-ci-abc-def'
|
|
```
|
|
</CodeGroup>
|
|
|
|
## RESUME JOB {#resume}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
RESUME JOB 'j-ci-abc-def'
|
|
```
|
|
</CodeGroup>
|
|
|
|
## CANCEL JOB {#cancel}
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
CANCEL JOB 'j-ci-abc-def'
|
|
```
|
|
</CodeGroup>
|
|
|
|
The job id is always a quoted string literal. All three take exactly one and
|
|
nothing after it: a second token on the line is a syntax error rather than
|
|
being ignored. Pause requires the deployment's pause-write opt-in and a
|
|
resumable job type; it may return `pausing` while workers drain, and resume
|
|
may return `still_pausing` until drain finishes.
|
|
|
|
<Note>
|
|
`PAUSE JOB`, `RESUME JOB` and `CANCEL JOB` require system `OPERATE` -- a
|
|
broader privilege than the `USAGE` that reading job state needs, since
|
|
these change what a running job does.
|
|
</Note>
|
|
|
|
<Note>
|
|
Cancellation is a request, matching the SDK's
|
|
[`cancel()`](/basics/jobs#managing): it does not guarantee the job stops before
|
|
doing more work, and asking twice or cancelling a finished job does nothing.
|
|
`CANCEL JOB` itself can be unavailable on an Enterprise cluster with no job registry
|
|
configured, which is a deployment condition rather than something you can work
|
|
around from SQL.
|
|
</Note>
|
|
|
|
## Compatibility {#compatibility}
|
|
|
|
`SHOW JOBS FOR <table>` (without the `TABLE` keyword), `SHOW JOB SUMMARY`,
|
|
and `SHOW JOB SPLITS` retain their existing behavior as compatibility forms.
|
|
Prefer `SHOW JOBS FOR TABLE`/`FOR JOB` and `DESCRIBE JOB` going forward. See
|
|
[`SHOW JOBS FOR JOB`](#show) for the per-split diagnostics
|
|
form -- each split is a child job, listed with its own phase and progress.
|
|
See [Watching a refresh](/sql/dml/refresh#watching) for `SHOW JOB SPLITS`'s
|
|
full column reference and a `DESCRIBE JOB` example.
|
|
|
|
## What to read next {#next}
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="Query and job" icon="hourglass-half" href="/basics/jobs">
|
|
The handle these statements are the SQL view of.
|
|
</Card>
|
|
<Card title="Intelligent Auto-Maintenance" icon="brain" href="/enterprise/intelligent-auto-maintenance#cleanup">
|
|
A job type the deployment schedules on its own, without a call.
|
|
</Card>
|
|
</CardGroup>
|