You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 81094b4
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: use group clustering terminology in aggregate execution (apache#24697)
## Which issue does this PR relate to?
- Part of apache#24438.
- Builds on the baseline test in apache#24737 (merged).
## Rationale for this change
Aggregate execution currently uses `InputOrderMode` to select execution
paths and recognize completed groups.
A group can be completed incrementally when its rows form one contiguous
run: once the run ends, that group cannot appear again in the same input
partition. Sorted input supplies this guarantee, and unsorted input can
supply it too:
```text
AAABBBCCCC -> sorted; groups can be completed incrementally
CCCAAABBB -> unsorted; groups can still be completed incrementally
```
This PR describes the input's _**clustering**_ guarantee with
`GroupClusteringMode` and uses clustering terminology throughout the
aggregate execution machinery. Aggregate construction derives the mode
directly from the existing ordering analysis. The follow-up in apache#24497
will also derive it from grouped equivalence properties.
## What changes are included in this PR?
- Replace the aggregate's `InputOrderMode` field with
`GroupClusteringMode::{None, Partial, Full}`:
- `None`: Groups have no apparent clustering guarantee.
- `Partial(indices)`: rows are contiguous on a subset of grouping
expressions; a change in that tuple completes all groups in the
preceding run.
- `Full`: rows are contiguous on the complete grouping tuple; a change
in that tuple completes the preceding group.
- Rename the stateful `GroupOrdering` tracker and its `Partial` and
`Full` implementations to `GroupClustering`, `GroupClusteringPartial`,
and `GroupClusteringFull`.
- Rename the ordered aggregate streams, shared table, and adjacent-key
group-values implementation to use clustered terminology,
- Preserve actual sort expressions and options through equivalence
properties and input-ordering requirements.
- Display `group_clustering_mode` in aggregate plans and document the
public API migration in the DataFusion 56 upgrade guide.
## Stack
1. [apache#24737 — test: cover unsorted contiguous groups in one
partition](apache#24737) (merged)
2. [apache#24697 — refactor: use group clustering terminology in aggregate
execution](apache#24697) ← **this
PR**
3. [apache#24698 — feat: add Grouped equivalence
properties](apache#24698)
4. [apache#24497 — feat: stream aggregates over grouped
input](apache#24497)
## Are there any user-facing changes?
Yes. This PR changes public Rust APIs:
- `AggregateExec::input_order_mode()` is replaced by
`AggregateExec::group_clustering_mode()`, returning the public
`GroupClusteringMode` enum.
- `AggregateExec::compute_properties` accepts `&GroupClusteringMode` in
place of `&InputOrderMode`.
- The public `GroupOrdering`, `GroupOrderingPartial`, and
`GroupOrderingFull` types in `aggregates::order` are renamed to
`GroupClustering`, `GroupClusteringPartial`, and `GroupClusteringFull`.
- `GroupClustering::try_new` takes `&GroupClusteringMode`;
`new_group_values` takes `&GroupClustering`.
Aggregate plan output uses `group_clustering_mode=Full` and
`group_clustering_mode=Partial(indices)` in place of
`ordering_mode=Sorted` and `ordering_mode=PartiallySorted(indices)`. SQL
results and aggregate execution-path selection retain their existing
behavior.
## Review this layer
[View this PR's
diff](https://github.com/apache/datafusion/pull/24697/files)
(cherry picked from commit d93699c)
0 commit comments