Repository navigation
Conversation
Closes apache#26748 When merging partition statistics in Statistics::try_merge_iter_with_ndv_fallback, inputs that are provably all-null (num_rows == null_count) or empty (num_rows == 0) have Precision::Absent for min_value and max_value. Merging these with existing exact bounds previously degraded the overall table or partition min/max to Precision::Absent. This change: 1. Ignores min/max updates from provably all-null or empty partition inputs. 2. Preserves known bounds established by non-null partitions regardless of partition ordering. 3. Preserves conservative degradation to Precision::Absent if null counts are absent when rows > 0. 4. Adds regression tests covering ordering invariance, empty partitions, multi-partitions, unknown null counts, and all-null-only inputs.
asolimando
left a comment
There was a problem hiding this comment.
LGTM on min/max, skipping all-null inputs and preserving values from the first real partition makes sense, and you also keep the demotion to Absent when counts are unknown. Tests make sense too.
I noticed that distinct_count suffers from the same problem, can you file a follow-up issue for that?
|
Thank you for the contribution. The change may well be correct, but I am closing this PR under our AI policy. Maintainer review time is the scarcest resource in this project. This account has opened more than 70 PRs across many repositories in the last month, which looks like GitHub "merge-maxxing" (collecting merged PRs) rather than work on a project the author uses. That suggests the changes aren't coming from someone who uses DataFusion, and that no human will be around to discuss review feedback and maintain the code. Reviewing PRs like this costs us more time than it saves. If you do use DataFusion and this fix matters to you, please pick the one change you care most about. Then open a focused PR with a short description in your own words, one you have reviewed and understand, and we'd be happy to help with review. |
|
Sorry that you have already reviewd this @asolimando |
Important
Fork CI setup: For pull requests from a fork to
main, enable workflows in your fork's Actions tab before you push.See the fork CI setup guide.
Which issue does this PR close?
Closes #26748
Rationale for this change
When merging partition statistics via
Statistics::try_merge_iter_with_ndv_fallback(for example, across multiple parquet files or parallel branches of aUnionExec), an all-null partition (num_rows == null_count) or empty partition (num_rows == 0) has no non-null values that can define a minimum or maximum (Precision::Absent).Under existing logic, merging
Precision::Absentfrom an all-null partition with known exact bounds (Precision::Exact(min),Precision::Exact(max)) causesprecision_minandprecision_maxto poison the merged result toPrecision::Absent. In relational semantics,MINandMAXaggregates ignore nulls. Erasing valid bounds when an empty or all-null partition is encountered causes downstream query optimizers to lose column range pruning opportunities.What changes are included in this PR?
is_known_all_null: Detects when a partition is provably empty (num_rows == Exact(0)) or provably all-null (num_rows == Exact(N)andnull_count == Exact(N)). Inexact estimates or absent row/null counts are not treated as all-null.Statistics::try_merge_iter_with_ndv_fallback, trackshas_non_null_rows: Vec<bool>across columns.Precision::Absentand markshas_non_null_rowsfalse for that column.min_valueandmax_value.null_countis unknown (Precision::Absent) whilenum_rows > 0, non-null values cannot be disproven, so standard conservative degradation toPrecision::Absentis preserved.What is the testing strategy for this PR?
Added comprehensive unit test
test_try_merge_iter_ignores_all_null_and_empty_inputs_for_min_maxindatafusion/common/src/stats.rscovering:Absent)Absent)Absent)0.0/-0.0)Validation results:
cargo fmt --check -p datafusion-common: PASS (clean formatting)cargo test -p datafusion-common --lib stats: PASS (78 passed; 0 failed)cargo clippy -p datafusion-common -- -D warnings: PASS (0 warnings)cargo test -p datafusion-physical-plan --lib union: PASS (28 passed; 0 failed)Are there any user-facing changes?
No breaking changes to public APIs. Fixes a statistics degradation bug where table min/max statistics were unnecessarily collapsed to
Precision::Absent.