feat(sql): expose durable job ids on query handles (#4941)

Expose the durable SQL registry id separately from the connection-scoped
query UUID. Rust and Python query handles and descriptions expose
optional `job_id`; result readers preserve it in schema metadata under
`x-lancedb-sql-job-id`, without adding business columns. Clients can
reopen that id with `open_job`.

Poll success and failure metadata update the same handle. A failure
before the first successful poll retains its job id and original
structured error. The cancellation documentation distinguishes the
Flight waiter from `cancel_job(job_id)`.

Validation on the designated EC2: the two focused error interoperability
tests and Ruff passed on `a8798e81`; delivery has the identical tree.
The preceding 51 Rust SQL tests and earlier 31 native Python SQL tests
are reused for unchanged coverage. Matching-runtime independent
acceptance remains pending.

Companion server change: https://github.com/lancedb/sophon/pull/10049.

Refs ENT-3562.
This commit is contained in:
Xuanwo
2026-11-10 19:47:30 +08:00
committed by GitHub
parent 3851938b6e
commit c0bd83ef29
9 changed files with 516 additions and 81 deletions
+9 -2
View File
@@ -31,6 +31,11 @@ impl Query {
self.inner.id()
}
#[getter]
pub fn job_id(&self) -> Option<String> {
self.inner.job_id()
}
pub fn describe(self_: PyRef<'_, Self>) -> PyResult<Bound<'_, PyAny>> {
let inner = self_.inner.clone();
future_into_py(self_.py(), async move {
@@ -63,6 +68,7 @@ impl Query {
#[derive(Clone)]
pub struct QueryDescription {
id: Uuid,
job_id: Option<String>,
status: String,
progress: Option<f64>,
expires_at: Option<DateTime<Utc>>,
@@ -72,8 +78,8 @@ pub struct QueryDescription {
impl QueryDescription {
fn __repr__(&self) -> String {
format!(
"QueryDescription(id={:?}, status={:?}, progress={:?}, expires_at={:?})",
self.id, self.status, self.progress, self.expires_at
"QueryDescription(id={:?}, job_id={:?}, status={:?}, progress={:?}, expires_at={:?})",
self.id, self.job_id, self.status, self.progress, self.expires_at
)
}
}
@@ -82,6 +88,7 @@ impl From<lancedb::sql::QueryDescription> for QueryDescription {
fn from(description: lancedb::sql::QueryDescription) -> Self {
Self {
id: description.id,
job_id: description.job_id,
status: description.status.to_string(),
progress: description.progress,
expires_at: description.expires_at,