feat: stream aggregates for group-contiguous 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.32% 81.31% -0.01%
==========================================
Files 1117 1117
Lines 396617 397331 +714
Branches 396617 397331 +714
==========================================
+ Hits 322549 323091 +542
- Misses 55201 55294 +93
- Partials 18867 18946 +79 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xavlee
force-pushed
the
feat/issue-24438-partition-disjoint-aggregates
branch
from
August 21, 2026 05:05
e3b1c0a to
6718bbf
Compare
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
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
Some data sources range-partition data into logical runs that are locally grouped by
(key, time)and non-overlapping on(key, date_bin(time)). Combining many such runs into fewer DataFusion output partitions keepstarget_partitionsnear the available CPU count, but the key ranges can reset between runs and therefore no longer form a global sort order.The input is still streamable: within each output stream, every
(key, date_bin(time))tuple occurs in one contiguous range. Once the next tuple begins, the aggregate knows that the previous group is complete. DataFusion currently has no way to express that guarantee independently of sort order, soAggregateExecfalls back to blocking hash aggregation.This PR models group contiguity as its own correctness property. It is intentionally neither an ordering guarantee nor an output-distribution guarantee.
What changes are included in this PR?
ExecutionPlan::group_contiguous_exprs,PlanProperties::with_group_contiguous_exprs, and a correspondingDataSourcehook. The expressions are the components of one composite tuple whose values must each occupy at most one contiguous range within every output stream.PlanProperties, so row-transparent wrappers that copy cached properties (includingCooperativeExec) preserve it without special-case forwarding.ProjectionExec. If any component cannot be mapped, the property is cleared. A source may declare a derived expression such asdate_bin(time)after validating its run boundaries; the projection does not infer that property fromtimealone.GroupCompletionModetoAggregateExec, separate fromInputOrderMode:InputOrderMode::Linear, and the aggregate advertises no false output ordering.FFI_PlanProperties, with both local and separately compiled cross-library coverage.This is complementary to #24501. That PR uses range partitioning to avoid a hash shuffle across DataFusion output partitions; this PR lets aggregation stream within each output partition after the source combines multiple non-overlapping logical runs. Neither property substitutes for the other.
Are these changes tested?
Yes. New coverage includes:
date_binprojection and all-or-nothing projection propagation;Validation on the final commit:
cargo test -p datafusion-physical-plan --lib(1,780 tests)cargo test -p datafusion-physical-optimizer(34 tests)cargo test -p datafusion-datasource --lib(178 tests)cargo test -p datafusion --test core_integration physical_optimizer(553 tests)cargo test -p datafusion-fficargo test -p datafusion-ffi --features integration-testscargo clippy -p datafusion-ffi --all-targets --all-features -- -D warningscargo clippy --all-targets --all-features -- -D warnings-D warningsrange_sorted_time_bin_agg.slttest on a combined branchThe benchmark measured approximately 937 µs for unordered hash aggregation and 746 µs for group-contiguous streaming on the development machine (about 20% lower latency for this workload).
cargo-semver-checkspasses fordatafusion,datafusion-datasource,datafusion-physical-plan, anddatafusion-physical-optimizer. It reports the expected added-field break for the appendedFFI_PlanProperties::group_contiguous_exprscallback.Are there any user-facing changes?
Yes. Data source and execution-plan implementors can opt into the new property. This is a correctness contract: an invalid declaration can cause an aggregate group to be emitted before all of its rows have been observed.
Appending the callback changes the FFI struct layout, so this PR requires the
api changelabel.