Skip to content

Commit 81094b4

Browse files
authored
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)
1 parent a9554d4 commit 81094b4

42 files changed

Lines changed: 672 additions & 485 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎datafusion/core/tests/dataframe/mod.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ async fn test_aggregate_with_pk2() -> Result<()> {
893893
assert_snapshot!(
894894
physical_plan_to_string(&df).await,
895895
@r"
896-
AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[], ordering_mode=Sorted
896+
AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[], group_clustering_mode=Full
897897
FilterExec: id@0 = 1 AND name@1 = a
898898
DataSourceExec: partitions=1, partition_sizes=[1]
899899
"
@@ -941,7 +941,7 @@ async fn test_aggregate_with_pk3() -> Result<()> {
941941
assert_snapshot!(
942942
physical_plan_to_string(&df).await,
943943
@r"
944-
AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[], ordering_mode=PartiallySorted([0])
944+
AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[], group_clustering_mode=Partial([0])
945945
FilterExec: id@0 = 1
946946
DataSourceExec: partitions=1, partition_sizes=[1]
947947
"
@@ -991,7 +991,7 @@ async fn test_aggregate_with_pk4() -> Result<()> {
991991
assert_snapshot!(
992992
physical_plan_to_string(&df).await,
993993
@r"
994-
AggregateExec: mode=Single, gby=[id@0 as id], aggr=[], ordering_mode=Sorted
994+
AggregateExec: mode=Single, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
995995
FilterExec: id@0 = 1
996996
DataSourceExec: partitions=1, partition_sizes=[1]
997997
"
@@ -3273,9 +3273,9 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti
32733273
assert_snapshot!(
32743274
union_with_mix_of_presorted_and_explicitly_resorted_inputs_impl(false).await?,
32753275
@r"
3276-
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], ordering_mode=Sorted
3276+
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
32773277
SortPreservingMergeExec: [id@0 ASC NULLS LAST]
3278-
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], ordering_mode=Sorted
3278+
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
32793279
UnionExec
32803280
DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], output_ordering=[id@0 ASC NULLS LAST], file_type=parquet
32813281
SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false]
@@ -3291,9 +3291,9 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti
32913291
assert_snapshot!(
32923292
union_with_mix_of_presorted_and_explicitly_resorted_inputs_impl(true).await?,
32933293
@r"
3294-
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], ordering_mode=Sorted
3294+
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
32953295
SortPreservingMergeExec: [id@0 ASC NULLS LAST]
3296-
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], ordering_mode=Sorted
3296+
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
32973297
UnionExec
32983298
DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], output_ordering=[id@0 ASC NULLS LAST], file_type=parquet
32993299
SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false]

‎datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use datafusion_common_runtime::JoinSet;
4141
use datafusion_functions_aggregate::sum::sum_udaf;
4242
use datafusion_physical_expr::PhysicalSortExpr;
4343
use datafusion_physical_expr::expressions::{Column, col, lit};
44-
use datafusion_physical_plan::InputOrderMode;
44+
use datafusion_physical_plan::aggregates::GroupClusteringMode;
4545
use test_utils::{StringBatchGenerator, add_empty_batches};
4646

4747
use datafusion_execution::TaskContext;
@@ -352,8 +352,8 @@ async fn run_aggregate_test(input1: Vec<RecordBatch>, group_by_columns: Vec<&str
352352
.unwrap(),
353353
);
354354
assert_ne!(
355-
aggregate_exec_running.input_order_mode(),
356-
&InputOrderMode::Linear,
355+
aggregate_exec_running.group_clustering_mode(),
356+
&GroupClusteringMode::None,
357357
"running aggregate should observe ordered input for group_by: {group_by:?}"
358358
);
359359

@@ -555,11 +555,11 @@ async fn verify_ordered_aggregate(frame: &DataFrame, expected_sort: bool) {
555555
if let Some(exec) = node.downcast_ref::<AggregateExec>() {
556556
if self.expected_sort {
557557
assert!(matches!(
558-
exec.input_order_mode(),
559-
InputOrderMode::PartiallySorted(_) | InputOrderMode::Sorted
558+
exec.group_clustering_mode(),
559+
GroupClusteringMode::Partial(_) | GroupClusteringMode::Full
560560
));
561561
} else {
562-
assert_eq!(*exec.input_order_mode(), InputOrderMode::Linear);
562+
assert_eq!(*exec.group_clustering_mode(), GroupClusteringMode::None);
563563
}
564564
}
565565
Ok(TreeNodeRecursion::Continue)

‎datafusion/core/tests/fuzz_cases/aggregation_fuzzer/query_builder.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ pub struct QueryBuilder {
9292
/// ...
9393
/// ```
9494
///
95-
/// More details can see [`GroupOrdering`].
95+
/// More details can see [`GroupClustering`].
9696
///
97-
/// [`GroupOrdering`]: datafusion_physical_plan::aggregates::order::GroupOrdering
97+
/// [`GroupClustering`]: datafusion_physical_plan::aggregates::order::GroupClustering
9898
dataset_sort_keys: Vec<Vec<String>>,
9999

100100
/// If we will also test the no grouping case like:

‎datafusion/core/tests/physical_optimizer/enforce_distribution.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,9 +3954,9 @@ fn preserve_ordering_for_streaming_sorted_aggregate() -> Result<()> {
39543954

39553955
let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT);
39563956
assert_plan!(plan_distrib, @r"
3957-
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[COUNT(b)], ordering_mode=Sorted
3957+
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
39583958
RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2, preserve_order=true, sort_exprs=a@0 ASC
3959-
AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[COUNT(b)], ordering_mode=Sorted
3959+
AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
39603960
DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
39613961
");
39623962

@@ -3988,9 +3988,9 @@ fn preserve_ordering_for_streaming_partially_sorted_aggregate() -> Result<()> {
39883988

39893989
let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT);
39903990
assert_plan!(plan_distrib, @r"
3991-
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], ordering_mode=PartiallySorted([0])
3991+
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_clustering_mode=Partial([0])
39923992
RepartitionExec: partitioning=Hash([a@0, b@1], 2), input_partitions=2, preserve_order=true, sort_exprs=a@0 ASC
3993-
AggregateExec: mode=Partial, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], ordering_mode=PartiallySorted([0])
3993+
AggregateExec: mode=Partial, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_clustering_mode=Partial([0])
39943994
DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
39953995
");
39963996

‎datafusion/core/tests/physical_optimizer/filter_pushdown.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ fn test_pushdown_through_aggregates_on_grouping_columns() {
737737
OptimizationTest:
738738
input:
739739
- FilterExec: b@1 = bar
740-
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], ordering_mode=PartiallySorted([0])
740+
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], group_clustering_mode=Partial([0])
741741
- FilterExec: a@0 = foo
742742
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
743743
output:
744744
Ok:
745-
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], ordering_mode=Sorted
745+
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], group_clustering_mode=Full
746746
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=a@0 = foo AND b@1 = bar
747747
"
748748
);
@@ -801,7 +801,7 @@ fn test_pushdown_through_aggregates_preserves_parent_filter_order() {
801801
output:
802802
Ok:
803803
- FilterExec: cnt@2 = 1
804-
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], ordering_mode=PartiallySorted([1])
804+
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], group_clustering_mode=Partial([1])
805805
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=b@1 = bar
806806
"
807807
);
@@ -2493,7 +2493,7 @@ fn test_pushdown_filter_on_non_first_grouping_column() {
24932493
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
24942494
output:
24952495
Ok:
2496-
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], ordering_mode=PartiallySorted([1])
2496+
- AggregateExec: mode=Final, gby=[a@0 as a, b@1 as b], aggr=[cnt], group_clustering_mode=Partial([1])
24972497
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=b@1 = bar
24982498
"
24992499
);
@@ -2632,7 +2632,7 @@ fn test_pushdown_grouping_sets_filter_on_common_column() {
26322632
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
26332633
output:
26342634
Ok:
2635-
- AggregateExec: mode=Final, gby=[(a@0 as a, b@1 as b), (NULL as a, b@1 as b)], aggr=[cnt], ordering_mode=PartiallySorted([1])
2635+
- AggregateExec: mode=Final, gby=[(a@0 as a, b@1 as b), (NULL as a, b@1 as b)], aggr=[cnt], group_clustering_mode=Partial([1])
26362636
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=b@1 = bar
26372637
"
26382638
);
@@ -2829,7 +2829,7 @@ fn test_pushdown_through_aggregate_with_reordered_input_columns() {
28292829
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
28302830
output:
28312831
Ok:
2832-
- AggregateExec: mode=Final, gby=[a@1 as a, b@2 as b], aggr=[cnt], ordering_mode=PartiallySorted([1])
2832+
- AggregateExec: mode=Final, gby=[a@1 as a, b@2 as b], aggr=[cnt], group_clustering_mode=Partial([1])
28332833
- ProjectionExec: expr=[c@2 as c, a@0 as a, b@1 as b]
28342834
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=b@1 = bar
28352835
"
@@ -2918,7 +2918,7 @@ fn test_pushdown_through_aggregate_grouping_sets_with_reordered_input() {
29182918
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
29192919
output:
29202920
Ok:
2921-
- AggregateExec: mode=Final, gby=[(a@1 as a, b@2 as b), (NULL as a, b@2 as b)], aggr=[cnt], ordering_mode=PartiallySorted([1])
2921+
- AggregateExec: mode=Final, gby=[(a@1 as a, b@2 as b), (NULL as a, b@2 as b)], aggr=[cnt], group_clustering_mode=Partial([1])
29222922
- ProjectionExec: expr=[c@2 as c, a@0 as a, b@1 as b]
29232923
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=b@1 = bar
29242924
"

‎datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ fn test_has_order_by() -> Result<()> {
401401
actual,
402402
@r"
403403
LocalLimitExec: fetch=10
404-
AggregateExec: mode=Single, gby=[a@0 as a], aggr=[], ordering_mode=Sorted
404+
AggregateExec: mode=Single, gby=[a@0 as a], aggr=[], group_clustering_mode=Full
405405
DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
406406
"
407407
);

‎datafusion/core/tests/physical_optimizer/pushdown_sort.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,13 @@ fn test_pushdown_through_blocking_node() {
731731
OptimizationTest:
732732
input:
733733
- SortExec: expr=[a@0 ASC], preserve_partitioning=[false]
734-
- AggregateExec: mode=Final, gby=[a@0 as a], aggr=[COUNT(b)], ordering_mode=Sorted
734+
- AggregateExec: mode=Final, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
735735
- SortExec: expr=[a@0 DESC NULLS LAST], preserve_partitioning=[false]
736736
- DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
737737
output:
738738
Ok:
739739
- SortExec: expr=[a@0 ASC], preserve_partitioning=[false]
740-
- AggregateExec: mode=Final, gby=[a@0 as a], aggr=[COUNT(b)], ordering_mode=Sorted
740+
- AggregateExec: mode=Final, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
741741
- SortExec: expr=[a@0 DESC NULLS LAST], preserve_partitioning=[false]
742742
- DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet, sort_order_for_reorder=[a@0 DESC NULLS LAST], reverse_row_groups=true
743743
"

‎datafusion/physical-plan/benches/dictionary_group_values.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use criterion::{
2929
};
3030
use datafusion_expr::EmitTo;
3131
use datafusion_physical_plan::aggregates::group_values::new_group_values;
32-
use datafusion_physical_plan::aggregates::order::GroupOrdering;
32+
use datafusion_physical_plan::aggregates::order::GroupClustering;
3333
use rand::rngs::StdRng;
3434
use rand::seq::SliceRandom;
3535
use rand::{Rng, SeedableRng};
@@ -106,7 +106,7 @@ fn bench_intern_emit(c: &mut Criterion) {
106106
b.iter_batched_ref(
107107
|| {
108108
(
109-
new_group_values(schema.clone(), &GroupOrdering::None)
109+
new_group_values(schema.clone(), &GroupClustering::None)
110110
.unwrap(),
111111
Vec::<usize>::with_capacity(size),
112112
)
@@ -151,7 +151,7 @@ fn bench_repeated_intern_emit(c: &mut Criterion) {
151151
b.iter_batched_ref(
152152
|| {
153153
(
154-
new_group_values(schema.clone(), &GroupOrdering::None)
154+
new_group_values(schema.clone(), &GroupClustering::None)
155155
.unwrap(),
156156
Vec::<usize>::with_capacity(size),
157157
)

‎datafusion/physical-plan/benches/partial_ordering.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use std::sync::Arc;
1919

2020
use arrow::array::{ArrayRef, Int32Array};
21-
use datafusion_physical_plan::aggregates::order::GroupOrderingPartial;
21+
use datafusion_physical_plan::aggregates::order::GroupClusteringPartial;
2222

2323
use criterion::{Criterion, criterion_group, criterion_main};
2424

@@ -34,20 +34,20 @@ fn create_test_arrays(num_columns: usize) -> Vec<ArrayRef> {
3434
.collect()
3535
}
3636
fn bench_new_groups(c: &mut Criterion) {
37-
let mut group = c.benchmark_group("group_ordering_partial");
37+
let mut group = c.benchmark_group("group_clustering_partial");
3838

39-
// Test with 1, 2, 4, and 8 order indices
39+
// Test with 1, 2, 4, and 8 grouping indices
4040
for num_columns in [1, 2, 4, 8] {
41-
let order_indices: Vec<usize> = (0..num_columns).collect();
41+
let grouping_indices: Vec<usize> = (0..num_columns).collect();
4242

43-
group.bench_function(format!("order_indices_{num_columns}"), |b| {
43+
group.bench_function(format!("grouping_indices_{num_columns}"), |b| {
4444
let batch_group_values = create_test_arrays(num_columns);
4545
let group_indices: Vec<usize> = (0..BATCH_SIZE).collect();
4646

4747
b.iter(|| {
48-
let mut ordering =
49-
GroupOrderingPartial::try_new(order_indices.clone()).unwrap();
50-
ordering
48+
let mut clustering =
49+
GroupClusteringPartial::try_new(grouping_indices.clone()).unwrap();
50+
clustering
5151
.new_groups(&batch_group_values, &group_indices, BATCH_SIZE)
5252
.unwrap();
5353
});

datafusion/physical-plan/src/aggregates/aggregate_hash_table/ordered_final_table.rs renamed to datafusion/physical-plan/src/aggregates/aggregate_hash_table/clustered_final_table.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
//! Aggregate table for final aggregation when partial-state input is ordered.
1919
//!
20-
//! See comments in [`super::ordered_partial_table`] for details.
20+
//! See comments in [`super::clustered_partial_table`] for details.
2121
2222
use std::sync::Arc;
2323

2424
use arrow::datatypes::SchemaRef;
2525
use arrow::record_batch::RecordBatch;
2626
use datafusion_common::Result;
2727

28-
use crate::InputOrderMode;
28+
use crate::aggregates::GroupClusteringMode;
2929
use crate::aggregates::aggregate_hash_table::FinalMarker;
3030
use crate::aggregates::group_values::GroupByMetrics;
3131
use crate::aggregates::{AggregateExec, AggregateMode};
3232

33-
use super::common_ordered::OrderedAggregateTable;
33+
use super::common_clustered::ClusteredAggregateTable;
3434

3535
/// Implementation specific to final aggregation, where the table stores partial
3636
/// aggregate states and the input rows are also partial states.
@@ -40,14 +40,14 @@ use super::common_ordered::OrderedAggregateTable;
4040
/// - Aggregate table stores: `k, sum(x), count(x)`
4141
/// - Input rows: `k, sum(x), count(x)`
4242
///
43-
/// See comments at [`OrderedAggregateTable`] for details.
44-
impl OrderedAggregateTable<FinalMarker> {
43+
/// See comments at [`ClusteredAggregateTable`] for details.
44+
impl ClusteredAggregateTable<FinalMarker> {
4545
pub(in crate::aggregates) fn new_with_input_order(
4646
agg: &AggregateExec,
4747
input_schema: &SchemaRef,
4848
output_schema: SchemaRef,
4949
batch_size: usize,
50-
input_order_mode: &InputOrderMode,
50+
group_clustering_mode: &GroupClusteringMode,
5151
group_by_metrics: GroupByMetrics,
5252
) -> Result<Self> {
5353
Self::new_for_mode(
@@ -56,7 +56,7 @@ impl OrderedAggregateTable<FinalMarker> {
5656
output_schema,
5757
Arc::clone(input_schema),
5858
batch_size,
59-
input_order_mode,
59+
group_clustering_mode,
6060
&AggregateMode::Final,
6161
vec![None; agg.aggr_expr.len()],
6262
group_by_metrics,
@@ -76,7 +76,7 @@ impl OrderedAggregateTable<FinalMarker> {
7676
self.aggregate_evaluated_batch(&evaluated_batch, true)
7777
}
7878

79-
/// See comments in `ordered_partial_stream::next_output_batch`
79+
/// See comments in `clustered_partial_stream::next_output_batch`
8080
pub(in crate::aggregates) fn next_output_batch(
8181
&mut self,
8282
) -> Result<Option<RecordBatch>> {

0 commit comments

Comments
 (0)