Skip to content

Commit 9402397

Browse files
committed
refactor: unify aggregate group clustering terminology
1 parent 901f239 commit 9402397

44 files changed

Lines changed: 420 additions & 419 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,9 +3422,9 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti
34223422
assert_snapshot!(
34233423
union_with_mix_of_presorted_and_explicitly_resorted_inputs_impl(false).await?,
34243424
@r"
3425-
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_completion_mode=Full
3425+
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
34263426
SortPreservingMergeExec: [id@0 ASC NULLS LAST]
3427-
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_completion_mode=Full
3427+
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
34283428
UnionExec
34293429
DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], output_ordering=[id@0 ASC NULLS LAST], file_type=parquet
34303430
SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false]
@@ -3440,9 +3440,9 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti
34403440
assert_snapshot!(
34413441
union_with_mix_of_presorted_and_explicitly_resorted_inputs_impl(true).await?,
34423442
@r"
3443-
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_completion_mode=Full
3443+
AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
34443444
SortPreservingMergeExec: [id@0 ASC NULLS LAST]
3445-
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_completion_mode=Full
3445+
AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], group_clustering_mode=Full
34463446
UnionExec
34473447
DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], output_ordering=[id@0 ASC NULLS LAST], file_type=parquet
34483448
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
@@ -48,7 +48,7 @@ use datafusion_execution::memory_pool::FairSpillPool;
4848
use datafusion_execution::runtime_env::RuntimeEnvBuilder;
4949
use datafusion_physical_expr::aggregate::AggregateExprBuilder;
5050
use datafusion_physical_plan::aggregates::{
51-
AggregateExec, AggregateMode, GroupCompletionMode, PhysicalGroupBy,
51+
AggregateExec, AggregateMode, GroupClusteringMode, PhysicalGroupBy,
5252
};
5353
use datafusion_physical_plan::metrics::MetricValue;
5454
use datafusion_physical_plan::{ExecutionPlan, collect, displayable};
@@ -353,8 +353,8 @@ async fn run_aggregate_test(input1: Vec<RecordBatch>, group_by_columns: Vec<&str
353353
.unwrap(),
354354
);
355355
assert_ne!(
356-
aggregate_exec_running.group_completion_mode(),
357-
&GroupCompletionMode::None,
356+
aggregate_exec_running.group_clustering_mode(),
357+
&GroupClusteringMode::None,
358358
"running aggregate should observe ordered input for group_by: {group_by:?}"
359359
);
360360

@@ -560,11 +560,11 @@ async fn verify_ordered_aggregate(frame: &DataFrame, expected_sort: bool) {
560560
);
561561
if self.expected_sort {
562562
assert!(matches!(
563-
exec.group_completion_mode(),
564-
GroupCompletionMode::Partial(_) | GroupCompletionMode::Full
563+
exec.group_clustering_mode(),
564+
GroupClusteringMode::Partial(_) | GroupClusteringMode::Full
565565
));
566566
} else {
567-
assert_eq!(*exec.group_completion_mode(), GroupCompletionMode::None);
567+
assert_eq!(*exec.group_clustering_mode(), GroupClusteringMode::None);
568568
}
569569
}
570570
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
@@ -93,9 +93,9 @@ pub struct QueryBuilder {
9393
/// ...
9494
/// ```
9595
///
96-
/// More details can see [`GroupCompletion`].
96+
/// More details can see [`GroupClustering`].
9797
///
98-
/// [`GroupCompletion`]: datafusion_physical_plan::aggregates::order::GroupCompletion
98+
/// [`GroupClustering`]: datafusion_physical_plan::aggregates::order::GroupClustering
9999
dataset_sort_keys: Vec<Vec<String>>,
100100

101101
/// 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
@@ -4867,9 +4867,9 @@ fn preserve_ordering_for_streaming_sorted_aggregate() -> Result<()> {
48674867

48684868
let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT);
48694869
assert_plan!(plan_distrib, @r"
4870-
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[COUNT(b)], group_completion_mode=Full
4870+
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
48714871
RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2, preserve_order=true, sort_exprs=a@0 ASC
4872-
AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[COUNT(b)], group_completion_mode=Full
4872+
AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[COUNT(b)], group_clustering_mode=Full
48734873
DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
48744874
");
48754875

@@ -4901,9 +4901,9 @@ fn preserve_ordering_for_streaming_partially_sorted_aggregate() -> Result<()> {
49014901

49024902
let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT);
49034903
assert_plan!(plan_distrib, @r"
4904-
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_completion_mode=Partial([0])
4904+
AggregateExec: mode=FinalPartitioned, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_clustering_mode=Partial([0])
49054905
RepartitionExec: partitioning=Hash([a@0, b@1], 2), input_partitions=2, preserve_order=true, sort_exprs=a@0 ASC
4906-
AggregateExec: mode=Partial, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_completion_mode=Partial([0])
4906+
AggregateExec: mode=Partial, gby=[a@0 as a, b@1 as b], aggr=[COUNT(c)], group_clustering_mode=Partial([0])
49074907
DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
49084908
");
49094909

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ fn test_has_order_by() -> Result<()> {
549549
actual,
550550
@r"
551551
LocalLimitExec: fetch=10
552-
AggregateExec: mode=Single, gby=[a@0 as a], aggr=[], group_completion_mode=Full
552+
AggregateExec: mode=Single, gby=[a@0 as a], aggr=[], group_clustering_mode=Full
553553
DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet
554554
"
555555
);

‎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)], group_completion_mode=Full
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)], group_completion_mode=Full
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: 7 additions & 7 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::{GroupCompletion, GroupCompletionFull};
32+
use datafusion_physical_plan::aggregates::order::{GroupClustering, GroupClusteringFull};
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(), &GroupCompletion::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(), &GroupCompletion::None)
154+
new_group_values(schema.clone(), &GroupClustering::None)
155155
.unwrap(),
156156
Vec::<usize>::with_capacity(size),
157157
)
@@ -172,7 +172,7 @@ fn bench_repeated_intern_emit(c: &mut Criterion) {
172172
group.finish();
173173
}
174174

175-
// GroupCompletion::Full -> GroupValuesColumn::<true>: scalar append_val/equal_to path.
175+
// GroupClustering::Full -> GroupValuesColumn::<true>: scalar append_val/equal_to path.
176176
fn bench_scalar_append_equal(c: &mut Criterion) {
177177
let mut group = c.benchmark_group("dict_scalar_append_equal");
178178
let schema = dict_schema();
@@ -192,7 +192,7 @@ fn bench_scalar_append_equal(c: &mut Criterion) {
192192
(
193193
new_group_values(
194194
schema.clone(),
195-
&GroupCompletion::Full(GroupCompletionFull::new()),
195+
&GroupClustering::Full(GroupClusteringFull::new()),
196196
)
197197
.unwrap(),
198198
Vec::<usize>::with_capacity(size),
@@ -227,7 +227,7 @@ fn bench_take_n(c: &mut Criterion) {
227227
b.iter_batched_ref(
228228
|| {
229229
(
230-
new_group_values(schema.clone(), &GroupCompletion::None).unwrap(),
230+
new_group_values(schema.clone(), &GroupClustering::None).unwrap(),
231231
Vec::<usize>::with_capacity(size),
232232
)
233233
},
@@ -298,7 +298,7 @@ fn bench_shared_values_arc(c: &mut Criterion) {
298298
b.iter_batched_ref(
299299
|| {
300300
(
301-
new_group_values(schema.clone(), &GroupCompletion::None)
301+
new_group_values(schema.clone(), &GroupClustering::None)
302302
.unwrap(),
303303
Vec::<usize>::with_capacity(size),
304304
)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ use datafusion_physical_expr::expressions::col;
3838
use datafusion_physical_expr::{LexOrdering, PhysicalSortExpr};
3939
use datafusion_physical_plan::aggregates::group_values::multi_group_by::GroupValuesColumn;
4040
use datafusion_physical_plan::aggregates::group_values::{GroupValues, new_group_values};
41-
use datafusion_physical_plan::aggregates::order::GroupCompletion;
41+
use datafusion_physical_plan::aggregates::order::GroupClustering;
4242
use datafusion_physical_plan::aggregates::{
43-
AggregateExec, AggregateMode, GroupCompletionMode, PhysicalGroupBy,
43+
AggregateExec, AggregateMode, GroupClusteringMode, PhysicalGroupBy,
4444
};
4545
use datafusion_physical_plan::test::TestMemoryExec;
4646
use datafusion_physical_plan::{ExecutionPlan, collect};
@@ -112,8 +112,8 @@ fn grouping(c: &mut Criterion) {
112112
let values: Box<dyn GroupValues> = if selected {
113113
new_group_values(
114114
Arc::clone(&schema),
115-
&GroupCompletion::try_new(
116-
&GroupCompletionMode::Full,
115+
&GroupClustering::try_new(
116+
&GroupClusteringMode::Full,
117117
)
118118
.unwrap(),
119119
)
@@ -160,7 +160,7 @@ fn check_case(schema: &SchemaRef, batches: &[Vec<ArrayRef>]) -> (usize, usize) {
160160
let mut hashed = GroupValuesColumn::<true>::try_new(Arc::clone(schema)).unwrap();
161161
let mut selected = new_group_values(
162162
Arc::clone(schema),
163-
&GroupCompletion::try_new(&GroupCompletionMode::Full).unwrap(),
163+
&GroupClustering::try_new(&GroupClusteringMode::Full).unwrap(),
164164
)
165165
.unwrap();
166166
let mut expected = Vec::new();
@@ -190,7 +190,7 @@ fn aggregate_plan(
190190
schema: &SchemaRef,
191191
keys: Vec<Vec<ArrayRef>>,
192192
sort_columns: &[&str],
193-
group_completion_mode: &GroupCompletionMode,
193+
group_clustering_mode: &GroupClusteringMode,
194194
) -> Arc<dyn ExecutionPlan> {
195195
let mut fields = schema.fields().to_vec();
196196
fields.push(Arc::new(Field::new("v", DataType::Int64, false)));
@@ -234,7 +234,7 @@ fn aggregate_plan(
234234
schema,
235235
)
236236
.unwrap();
237-
assert_eq!(plan.group_completion_mode(), group_completion_mode);
237+
assert_eq!(plan.group_clustering_mode(), group_clustering_mode);
238238
Arc::new(plan)
239239
}
240240

@@ -248,7 +248,7 @@ fn aggregation(c: &mut Criterion) {
248248
for run_length in [1, 8, 128, 8192] {
249249
let (schema, keys) = inputs(run_length, 8192, strings);
250250
let plan =
251-
aggregate_plan(&schema, keys, &["a", "b"], &GroupCompletionMode::Full);
251+
aggregate_plan(&schema, keys, &["a", "b"], &GroupClusteringMode::Full);
252252
let name =
253253
format!("{}_run{run_length}", if strings { "string" } else { "int" });
254254
group.bench_function(name, |b| {
@@ -293,7 +293,7 @@ fn partially_ordered_aggregation(c: &mut Criterion) {
293293
&schema,
294294
keys,
295295
&["a"],
296-
&GroupCompletionMode::Partial(vec![0]),
296+
&GroupClusteringMode::Partial(vec![0]),
297297
);
298298
let runtime = Runtime::new().unwrap();
299299
let mut group = c.benchmark_group("partially_ordered_aggregate_exec");

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

Lines changed: 5 additions & 5 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::GroupCompletionPartial;
21+
use datafusion_physical_plan::aggregates::order::GroupClusteringPartial;
2222

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

@@ -34,7 +34,7 @@ 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_completion_partial");
37+
let mut group = c.benchmark_group("group_clustering_partial");
3838

3939
// Test with 1, 2, 4, and 8 grouping indices
4040
for num_columns in [1, 2, 4, 8] {
@@ -45,9 +45,9 @@ fn bench_new_groups(c: &mut Criterion) {
4545
let group_indices: Vec<usize> = (0..BATCH_SIZE).collect();
4646

4747
b.iter(|| {
48-
let mut completion =
49-
GroupCompletionPartial::try_new(grouping_indices.clone()).unwrap();
50-
completion
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/clustered_final_table.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use arrow::record_batch::RecordBatch;
2626
use datafusion_common::Result;
2727

2828
use crate::aggregates::aggregate_hash_table::FinalMarker;
29-
use crate::aggregates::order::GroupCompletionMode;
29+
use crate::aggregates::order::GroupClusteringMode;
3030
use crate::aggregates::{AggregateExec, AggregateMode, group_values::AccumulatorPhase};
3131

3232
use super::common::HashAggregateAccumulator;
@@ -42,19 +42,19 @@ use super::common_clustered::{ClusteredAggregateTable, ClusteredAggregateTableMe
4242
///
4343
/// See comments at [`ClusteredAggregateTable`] for details.
4444
impl ClusteredAggregateTable<FinalMarker> {
45-
pub(in crate::aggregates) fn new_with_group_completion(
45+
pub(in crate::aggregates) fn new_with_group_clustering(
4646
agg: &AggregateExec,
4747
input_schema: &SchemaRef,
4848
output_schema: SchemaRef,
49-
group_completion_mode: &GroupCompletionMode,
49+
group_clustering_mode: &GroupClusteringMode,
5050
metrics: ClusteredAggregateTableMetrics,
5151
) -> Result<Self> {
5252
Self::new_for_mode(
5353
agg,
5454
input_schema,
5555
output_schema,
5656
Arc::clone(input_schema),
57-
group_completion_mode,
57+
group_clustering_mode,
5858
&AggregateMode::Final,
5959
vec![None; agg.aggr_expr().len()],
6060
metrics,
@@ -88,7 +88,7 @@ impl ClusteredAggregateTable<FinalMarker> {
8888
if self.is_empty() {
8989
return Ok(None);
9090
}
91-
let Some(emit_to) = self.group_completion().emit_to() else {
91+
let Some(emit_to) = self.group_clustering().emit_to() else {
9292
return Ok(None);
9393
};
9494
self.materialize_groups(

0 commit comments

Comments
 (0)