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(<same id>).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.
This commit is contained in:
Xuanwo
2026-11-17 22:49:40 +08:00
committed by GitHub
parent 1670859327
commit 961a4518fd
+43
View File
@@ -335,6 +335,10 @@ impl<S: HttpSend> crate::job::JobHandle for FreshnessJob<S> {
crate::job::JobHandle::events(&self.inner, request).await
}
async fn stats(&self) -> Result<Option<String>> {
crate::job::JobHandle::stats(&self.inner).await
}
async fn wait(&self) -> Result<crate::job::TerminalResult> {
crate::job::JobHandle::wait_with_progress(self, None).await
}
@@ -424,6 +428,10 @@ impl<S: HttpSend> crate::job::JobHandle for MaterializedViewRefreshJob<S> {
crate::job::JobHandle::events(&self.inner, request).await
}
async fn stats(&self) -> Result<Option<String>> {
crate::job::JobHandle::stats(&self.inner).await
}
async fn wait(&self) -> Result<crate::job::TerminalResult> {
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"));