This is an automated email from the ASF dual-hosted git repository.
github-bot 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 e65dafe733 minor: Fix parquet pruning metrics display order (#18379)
e65dafe733 is described below
commit e65dafe7330f0324b28d9037f4e5a73cf12e99ce
Author: Yongting You <[email protected]>
AuthorDate: Fri Oct 31 18:25:21 2025 +0800
minor: Fix parquet pruning metrics display order (#18379)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
It's better to let pruning metrics in parquet displayed in an order that
is the same as the actual pruning order:
```
metrics=...files_ranges_pruned_statistics=21 total → 3 matched,
row_groups_pruned_statistics=1 total → 1 matched,
row_groups_pruned_bloom_filter=1 total → 1 matched,
page_index_rows_pruned=748901 total → 19813 matched...
```
Now it's ordered alphabetically.
See https://github.com/apache/datafusion/pull/18321#event-20598897462
for reproducing.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
Update the sort key API in `MetricValue`, to let the parquet pruning
metrics display in the expected order.
## Are these changes tested?
UT
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
datafusion/core/tests/sql/explain_analyze.rs | 15 ++++++++++++
datafusion/physical-plan/src/metrics/value.rs | 35 ++++++++++++++++++---------
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/datafusion/core/tests/sql/explain_analyze.rs
b/datafusion/core/tests/sql/explain_analyze.rs
index b3e8dac111..80fe8ebda0 100644
--- a/datafusion/core/tests/sql/explain_analyze.rs
+++ b/datafusion/core/tests/sql/explain_analyze.rs
@@ -860,6 +860,21 @@ async fn parquet_explain_analyze() {
&formatted,
"row_groups_pruned_statistics=1 total \u{2192} 1 matched"
);
+
+ // The order of metrics is expected to be the same as the actual pruning
order
+ // (file-> row-group -> page)
+ let i_file = formatted.find("files_ranges_pruned_statistics").unwrap();
+ let i_rowgroup_stat =
formatted.find("row_groups_pruned_statistics").unwrap();
+ let i_rowgroup_bloomfilter =
+ formatted.find("row_groups_pruned_bloom_filter").unwrap();
+ let i_page = formatted.find("page_index_rows_pruned").unwrap();
+
+ assert!(
+ (i_file < i_rowgroup_stat)
+ && (i_rowgroup_stat < i_rowgroup_bloomfilter)
+ && (i_rowgroup_bloomfilter < i_page),
+ "The parquet pruning metrics should be displayed in an order of:
file range -> row group statistics -> row group bloom filter -> page index."
+ );
}
// This test reproduces the behavior described in
diff --git a/datafusion/physical-plan/src/metrics/value.rs
b/datafusion/physical-plan/src/metrics/value.rs
index 3b8aa7a2bd..e7020a499d 100644
--- a/datafusion/physical-plan/src/metrics/value.rs
+++ b/datafusion/physical-plan/src/metrics/value.rs
@@ -749,17 +749,30 @@ impl MetricValue {
Self::ElapsedCompute(_) => 1,
Self::OutputBytes(_) => 2,
// Other metrics
- Self::PruningMetrics { .. } => 3,
- Self::SpillCount(_) => 4,
- Self::SpilledBytes(_) => 5,
- Self::SpilledRows(_) => 6,
- Self::CurrentMemoryUsage(_) => 7,
- Self::Count { .. } => 8,
- Self::Gauge { .. } => 9,
- Self::Time { .. } => 10,
- Self::StartTimestamp(_) => 11, // show timestamps last
- Self::EndTimestamp(_) => 12,
- Self::Custom { .. } => 13,
+ Self::PruningMetrics { name, .. } => match name.as_ref() {
+ // The following metrics belong to `DataSourceExec` with a
Parquet data source.
+ // They are displayed in a specific order that reflects the
actual pruning process,
+ // from coarse-grained to fine-grained pruning levels.
+ //
+ // You may update these metrics as long as their relative
order remains unchanged.
+ //
+ // Reference PR:
<https://github.com/apache/datafusion/pull/18379>
+ "files_ranges_pruned_statistics" => 3,
+ "row_groups_pruned_statistics" => 4,
+ "row_groups_pruned_bloom_filter" => 5,
+ "page_index_rows_pruned" => 6,
+ _ => 7,
+ },
+ Self::SpillCount(_) => 8,
+ Self::SpilledBytes(_) => 9,
+ Self::SpilledRows(_) => 10,
+ Self::CurrentMemoryUsage(_) => 11,
+ Self::Count { .. } => 12,
+ Self::Gauge { .. } => 13,
+ Self::Time { .. } => 14,
+ Self::StartTimestamp(_) => 15, // show timestamps last
+ Self::EndTimestamp(_) => 16,
+ Self::Custom { .. } => 17,
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]