feat: stream aggregates for partition-disjoint input - #24497
Draft
xavlee wants to merge 1 commit into
Draft
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24497 +/- ##
==========================================
- Coverage 81.24% 81.23% -0.01%
==========================================
Files 1113 1113
Lines 392744 393384 +640
Branches 392744 393384 +640
==========================================
+ Hits 319090 319582 +492
- Misses 54900 54981 +81
- Partials 18754 18821 +67 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Data can be range-partitioned into logical runs that are each locally grouped by
(key, time)and non-overlapping on(key, date_bin(time)). Concatenating several runs into one DataFusion execution partition resets the global sort order, soAggregateExeccurrently falls back to blocking hash aggregation even though every group remains one contiguous range.This change lets a data source communicate that stronger contiguity guarantee independently of physical sort order, allowing the first aggregate after an optional projection to emit completed groups incrementally.
What changes are included in this PR?
ExecutionPlan::partition_disjoint_exprsand the correspondingDataSourcehook. The returned expressions form one composite tuple whose values must occur in a single contiguous range within each output partition.ProjectionExec; if any component cannot be projected, clear the property.AggregateExecderive a private group-completion mode from the property while retainingInputOrderMode::Linear, so execution can reuse the existing ordered aggregate paths without advertising a false output ordering.A source may declare a derived expression such as
(key, date_bin(time))after verifying that logical-run boundaries do not split a bin. The projection path maps that expression but deliberately does not infer it from(key, time).Are these changes tested?
Yes. Coverage includes:
date_binprojection;Validation run locally:
cargo test -p datafusion-physical-plan --lib(1,765 tests)cargo test -p datafusion-datasource --lib(178 tests)cargo test -p datafusion --test core_integration physical_optimizer(553 tests)./dev/rust_lint.shcargo clippy --all-targets --all-features -- -D warningsThe added benchmark measured approximately 885 us for unordered hash aggregation versus 663 us for partition-disjoint streaming on the development machine (about 25% faster for this workload).
Are there any user-facing changes?
Yes. Data source and execution-plan implementors can opt into the new property. It is a correctness contract: an invalid declaration can cause an aggregate group to be emitted before all of its rows have been observed.
The new FFI callback adds a field to the versioned
FFI_ExecutionPlanstruct.cargo-semver-checkstherefore reports the expected major-version FFI layout change;datafusion-physical-plananddatafusion-datasourceotherwise pass all semver checks.