feat: stream exact group-contiguous aggregates - #24497
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24497 +/- ##
==========================================
- Coverage 81.45% 81.43% -0.03%
==========================================
Files 1118 1119 +1
Lines 399685 401024 +1339
Branches 399685 401024 +1339
==========================================
+ Hits 325576 326582 +1006
- Misses 55103 55321 +218
- Partials 19006 19121 +115 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e3b1c0a to
6718bbf
Compare
Why does it need a new property? I think this notion is designed to be covered y the existing ordering / monotonic analyses |
|
Oh, I see, somehow the external system knows the data is not sorted but is non overlapping I think this is going to be really hard to manage / ensure through the plan -- we will need to ensure that every operator properly reports if it will propagate this property or not I am not sure this is something we want to complicate datafusion with |
|
@NGA-TRAN can you help evaluate this PR for its impact and if we will be able to keep this property in tact? |
|
Hi Andrew, thanks for taking an initial look. Apologies that this is still verymuch a draft. I agree that propagating another physical property through the plan would be a little complicated. I was hoping we would narrow the
|
|
@alamb : I added a comment in the ticket
The impact of this PR is huge for telemetry use cases of AI frontiers as I described in the comment above
This property, like some properties, will be no longer available after certain operators so I think it would wok the same. I agree the propagation is a bit more complicated than usual but we work together to split this PR into smaller ones and will look into design carefully to avoid a lot of side effect. I think we would be able to make the design simpler |
c6e6b16 to
4b01e80
Compare
4b01e80 to
c3ce192
Compare
c3ce192 to
3750856
Compare
3750856 to
b990019
Compare
Which issue does this PR close?
Rationale for this change
Large pre-partitioned datasets can contain many more logical runs than available CPU cores. A source can combine several runs into each DataFusion output partition while preserving the invariant that every complete grouping tuple occupies one contiguous range. Capturing that invariant lets the first aggregate emit completed groups as the stream advances and bound its live group state to the active tuple range.
For example, a source can certify
(key, date_bin(time))after validating its logical run boundaries. The combined stream may reset tuple values between runs while every distinct tuple still appears in one range.What changes are included?
This three-commit stack implements the following path:
AggregateExeccompares the asserted tuple with the completeGROUP BYtuple using input equivalence properties. Matching supports equivalent expressions and tuple permutation.An exact match establishes
GroupCompletionMode::Full.InputOrderModecontinues to describe the input ordering, so an unsorted input retainsInputOrderMode::Linear. The aggregate selects DataFusion's existing full group-completion tables and streams, reports incremental emission according to its input pipeline, and emits each group when the next tuple begins.The first aggregate consumes the assertion and produces the default-empty assertion on its output. Its
benefits_from_input_partitioningresult protects the contiguous input path when that assertion supplies the stronger completion capability. Aggregates using ordering-derived completion retain their existing partitioning calculation.Stack
Linear -> None -> Finalblocking regression.b9900193f) adds the exact-match aggregate consumer and updates the baseline into paired asserted and default-empty cases.This draft carries all three commits so reviewers can inspect the integrated behavior. As the prerequisite PRs merge, the branch can be rebased to the remaining commit.
Relationship to #24501
This PR establishes within-stream group completion. #24501 establishes cross-partition distribution satisfaction for
Range([timestamp])projected throughdate_binanddate_trunc. Together, those capabilities support a single-stage partitioned streaming aggregate when the source supplies both facts.Are these changes tested?
Coverage includes:
InputOrderMode::Linear, the asserted input becomesFulland emits before EOF, and the default-empty input remainsNoneand pending;date_binexpression;benefits_from_input_partitioningbehavior;PlanPropertieschild replacement;DataSourceExec,ProjectionExec, andCooperativeExecforwarding; andValidation on the three-commit stack:
cargo test -p datafusion-physical-plan --lib(1,789 tests)cargo test -p datafusion-datasource --lib(175 tests)cargo-semver-checksfor both affected cratesrange_sorted_time_bin_agg.slton a combined branch with feat: skip hash shuffle for date_bin/date_trunc on Range([timestamp]) #24501Are there any user-facing changes?
ExecutionPlanandDataSourceimplementors can declare a complete tuple throughgroup_contiguous_exprs. An exact aggregate grouping match activates incremental group completion within each input partition.