From 4551f1df80afe44bd95f7fc1d780125ec69ed2ce Mon Sep 17 00:00:00 2001 From: Gabriel <45515538+gabotechs@users.noreply.github.com> Date: Tue, 3 Mar 2026 07:55:00 +0100 Subject: [PATCH] Fix custom metric display (#20643) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Which issue does this PR close? - Closes part of https://github.com/datafusion-contrib/datafusion-distributed/issues/361. ## Rationale for this change The custom metrics display is unnecessarily prepending the name of the metric during the display: ``` network_latency_min_2=name:network_latency_min 274.88µs ``` When it should just be: ``` network_latency_min_2=274.88µs ``` ## What changes are included in this PR? Fix to the display ## Are these changes tested? yes, by a new test ## Are there any user-facing changes? (cherry picked from commit 657887dca9e60265ba034533793734409c3f5246) --- datafusion/physical-expr-common/src/metrics/value.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/datafusion/physical-expr-common/src/metrics/value.rs b/datafusion/physical-expr-common/src/metrics/value.rs index 26f68980bad8e..d9e93aa361c12 100644 --- a/datafusion/physical-expr-common/src/metrics/value.rs +++ b/datafusion/physical-expr-common/src/metrics/value.rs @@ -1050,8 +1050,8 @@ impl Display for MetricValue { write!(f, "{pruning_metrics}") } Self::Ratio { ratio_metrics, .. } => write!(f, "{ratio_metrics}"), - Self::Custom { name, value } => { - write!(f, "name:{name} {value}") + Self::Custom { value, .. } => { + write!(f, "{value}") } } } @@ -1146,6 +1146,12 @@ mod tests { } } + #[test] + fn test_display_custom_metric() { + let custom_val = new_custom_counter("hi", 11); + assert_eq!(custom_val.to_string(), "count: 11"); + } + #[test] fn test_display_output_rows() { let count = Count::new();