This is an automated email from the ASF dual-hosted git repository.
weijun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 3bd41bcd07 Sort metrics alphabetically in EXPLAIN ANALYZE output
(#12568)
3bd41bcd07 is described below
commit 3bd41bcd076efd05026f5b6f236fa3fecdfea6bc
Author: Val Lorentz <[email protected]>
AuthorDate: Sun Sep 22 06:29:24 2024 +0200
Sort metrics alphabetically in EXPLAIN ANALYZE output (#12568)
---
datafusion/physical-plan/src/metrics/mod.rs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/datafusion/physical-plan/src/metrics/mod.rs
b/datafusion/physical-plan/src/metrics/mod.rs
index 9232865aa0..ead0ca3369 100644
--- a/datafusion/physical-plan/src/metrics/mod.rs
+++ b/datafusion/physical-plan/src/metrics/mod.rs
@@ -301,8 +301,12 @@ impl MetricsSet {
/// Sort the order of metrics so the "most useful" show up first
pub fn sorted_for_display(mut self) -> Self {
- self.metrics
- .sort_unstable_by_key(|metric| metric.value().display_sort_key());
+ self.metrics.sort_unstable_by_key(|metric| {
+ (
+ metric.value().display_sort_key(),
+ metric.value().name().to_owned(),
+ )
+ });
self
}
@@ -665,7 +669,9 @@ mod tests {
MetricBuilder::new(&metrics).end_timestamp(0);
MetricBuilder::new(&metrics).start_timestamp(0);
MetricBuilder::new(&metrics).elapsed_compute(0);
+ MetricBuilder::new(&metrics).counter("the_second_counter", 0);
MetricBuilder::new(&metrics).counter("the_counter", 0);
+ MetricBuilder::new(&metrics).counter("the_third_counter", 0);
MetricBuilder::new(&metrics).subset_time("the_time", 0);
MetricBuilder::new(&metrics).output_rows(0);
let metrics = metrics.clone_inner();
@@ -675,9 +681,9 @@ mod tests {
n.join(", ")
}
- assert_eq!("end_timestamp, start_timestamp, elapsed_compute,
the_counter, the_time, output_rows", metric_names(&metrics));
+ assert_eq!("end_timestamp, start_timestamp, elapsed_compute,
the_second_counter, the_counter, the_third_counter, the_time, output_rows",
metric_names(&metrics));
let metrics = metrics.sorted_for_display();
- assert_eq!("output_rows, elapsed_compute, the_counter, the_time,
start_timestamp, end_timestamp", metric_names(&metrics));
+ assert_eq!("output_rows, elapsed_compute, the_counter,
the_second_counter, the_third_counter, the_time, start_timestamp,
end_timestamp", metric_names(&metrics));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]