diff --git a/rust/lancedb/src/query.rs b/rust/lancedb/src/query.rs index 2acde4ff2..6f588d2c5 100644 --- a/rust/lancedb/src/query.rs +++ b/rust/lancedb/src/query.rs @@ -1894,12 +1894,11 @@ impl TakeQuery { } } - fn wrap_offsets_report( + fn wrap_offsets_explanation( lookup: &str, occurrence_count: usize, output_offset: usize, output_limit: Option, - node_suffix: &str, ) -> String { fn indent(plan: &str, spaces: usize) -> String { let indentation = " ".repeat(spaces); @@ -1910,7 +1909,7 @@ impl TakeQuery { } let restored = format!( - "TakeRestoreExec: occurrences={occurrence_count}{node_suffix}\n CoalescePartitionsExec{node_suffix}\n{}", + "TakeRestoreExec: occurrences={occurrence_count}\n CoalescePartitionsExec\n{}", indent(lookup, 4) ); @@ -1919,7 +1918,7 @@ impl TakeQuery { .map(|limit| limit.to_string()) .unwrap_or_else(|| "None".to_string()); format!( - "GlobalLimitExec: skip={output_offset}, fetch={fetch}{node_suffix}\n{}", + "GlobalLimitExec: skip={output_offset}, fetch={fetch}\n{}", indent(&restored, 2) ) } else { @@ -2044,12 +2043,11 @@ impl ExecutableQuery for TakeQuery { .parent .explain_plan(&AnyQuery::Query(request), verbose) .await?; - return Ok(Self::wrap_offsets_report( + return Ok(Self::wrap_offsets_explanation( &lookup, offsets.len(), output_offset, output_limit, - "", )); } @@ -2058,21 +2056,17 @@ impl ExecutableQuery for TakeQuery { } async fn analyze_plan_with_options(&self, options: QueryExecutionOptions) -> Result { - if let Some(offsets) = &self.offsets { + if self.offsets.is_some() { if self.parent.analyze_plan_is_remote() { - let (request, _, _, output_offset, output_limit) = - self.prepare_offsets_lookup().await?; - let backend_analysis = self + let (request, _, _, _, _) = self.prepare_offsets_lookup().await?; + // Remote analysis is owned by the service. The current wire + // request represents only the distinct-row lookup, so return + // the service report unchanged instead of fabricating metrics + // for client-side restoration operators. + return self .parent .analyze_plan(&AnyQuery::Query(request), options) - .await?; - return Ok(Self::wrap_offsets_report( - &backend_analysis, - offsets.len(), - output_offset, - output_limit, - ", metrics=[unavailable: client-side operator]", - )); + .await; } let plan = self.create_plan(options).await?; diff --git a/rust/lancedb/src/remote/table.rs b/rust/lancedb/src/remote/table.rs index 36544ff6a..5bcdfa673 100644 --- a/rust/lancedb/src/remote/table.rs +++ b/rust/lancedb/src/remote/table.rs @@ -5053,7 +5053,7 @@ mod tests { } #[tokio::test] - async fn test_take_offsets_analyze_plan_preserves_remote_metrics() { + async fn test_take_offsets_analyze_plan_delegates_to_remote() { let table = Table::new_with_handler("my_table", |request| { assert_eq!(request.method(), "POST"); assert_eq!(request.url().path(), "/v1/table/my_table/analyze_plan/"); @@ -5082,10 +5082,7 @@ mod tests { .await .unwrap(); - assert!(analyzed.contains("GlobalLimitExec")); - assert!(analyzed.contains("TakeRestoreExec")); - assert!(analyzed.contains("metrics=[unavailable: client-side operator]")); - assert!(analyzed.contains("Remote analyzed plan: worker metrics")); + assert_eq!(analyzed, "Remote analyzed plan: worker metrics"); } #[tokio::test]