From 961a4518fd67677779e751de698c2815a6c318c3 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 17 Nov 2026 22:49:40 +0800 Subject: [PATCH] fix(remote): forward job statistics through refresh handles (#5071) A Function refresh submitted through the LanceDB SDK returns a handle wrapped for read-freshness tracking. lancedb/lancedb#5016 added canonical `Job::stats()` on the server-job handle, but the refresh wrapper did not forward `stats`. The returned handle therefore reported `job statistics is only available for server-side jobs`, while `db.open_job().stats()` returned the server report. Forward `stats` through the refresh wrapper and cover it at the public refresh entry point. The regression submits with `refresh_column_async`, then reads `stats` from that returned handle without reopening the job. With the forwarding removed, the test fails with the same `NotSupported` error; with the change, it passes. Validation on `57b20fb11`: the targeted Rust test passed, `cargo fmt --check` passed, and `cargo clippy -p lancedb --features remote --lib --tests -- -D warnings` passed. Part of ENT-3974. --- rust/lancedb/src/remote/table.rs | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/rust/lancedb/src/remote/table.rs b/rust/lancedb/src/remote/table.rs index ad53f8722..2ed46147d 100644 --- a/rust/lancedb/src/remote/table.rs +++ b/rust/lancedb/src/remote/table.rs @@ -335,6 +335,10 @@ impl crate::job::JobHandle for FreshnessJob { crate::job::JobHandle::events(&self.inner, request).await } + async fn stats(&self) -> Result> { + crate::job::JobHandle::stats(&self.inner).await + } + async fn wait(&self) -> Result { crate::job::JobHandle::wait_with_progress(self, None).await } @@ -424,6 +428,10 @@ impl crate::job::JobHandle for MaterializedViewRefreshJob { crate::job::JobHandle::events(&self.inner, request).await } + async fn stats(&self) -> Result> { + crate::job::JobHandle::stats(&self.inner).await + } + async fn wait(&self) -> Result { crate::job::JobHandle::wait_with_progress(self, None).await } @@ -11601,6 +11609,19 @@ mod tests { .to_string(), ) .unwrap(), + "/v1/jobs/stats" => { + let body: serde_json::Value = + serde_json::from_slice(request.body().unwrap().as_bytes().unwrap()) + .unwrap(); + assert_eq!(body["job_id"], "job-1"); + http::Response::builder() + .status(200) + .body( + r#"{"job_id":"job-1","profile":{},"report":"Function job: finished\nRows: 1600\n"}"# + .to_string(), + ) + .unwrap() + } "/v1/table/ns$view/describe/" => http::Response::builder() .status(200) .body(r#"{"version":42,"schema":{"fields":[]}}"#.to_string()) @@ -11623,6 +11644,10 @@ mod tests { })); assert_eq!(job.id(), Some("job-1")); + assert_eq!( + job.stats().await.unwrap().as_deref(), + Some("Function job: finished\nRows: 1600\n") + ); let observations = Arc::new(Mutex::new(Vec::new())); let observed = observations.clone(); let result: RefreshMaterializedViewResult = if with_progress { @@ -13142,6 +13167,20 @@ mod tests { .body(events.clone()) .unwrap() } + "/v1/jobs/stats" => { + let body: serde_json::Value = + serde_json::from_slice(request.body().unwrap().as_bytes().unwrap()) + .unwrap(); + assert_eq!(body["job_id"], "j-42"); + http::Response::builder() + .status(200) + .body( + r#"{"job_id":"j-42","profile":{},"report":"Function job: finished\nRows: 1600\n"}"# + .as_bytes() + .to_vec(), + ) + .unwrap() + } "/v1/jobs/timeline" => http::Response::builder().status(200) .body(br#"{"traceEvents":[],"metadata":{"partial":true}}"#.to_vec()).unwrap(), other => panic!("unexpected path {other}"), @@ -13149,6 +13188,10 @@ mod tests { }); let job = table.refresh_column_async("doubled").await.unwrap(); + assert_eq!( + job.stats().await.unwrap().as_deref(), + Some("Function job: finished\nRows: 1600\n") + ); job.refresh().await.unwrap(); assert_eq!(job.state().as_deref(), Some("running")); assert_eq!(job.job_type().as_deref(), Some("refresh_column"));