Skip to content

Commit b813513

Browse files
authored
Minor: Make group_schema as PhysicalGroupBy method (#14064)
* group shema as method Signed-off-by: Jay Zhan <[email protected]> * fmt Signed-off-by: Jay Zhan <[email protected]> --------- Signed-off-by: Jay Zhan <[email protected]>
1 parent 4b7281e commit b813513

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ impl PhysicalGroupBy {
250250
}
251251
}
252252

253+
pub fn group_schema(&self, schema: &Schema) -> Result<SchemaRef> {
254+
Ok(Arc::new(Schema::new(self.group_fields(schema)?)))
255+
}
256+
253257
/// Returns the fields that are used as the grouping keys.
254258
fn group_fields(&self, input_schema: &Schema) -> Result<Vec<Field>> {
255259
let mut fields = Vec::with_capacity(self.num_group_exprs());
@@ -924,10 +928,6 @@ fn create_schema(
924928
))
925929
}
926930

927-
fn group_schema(input_schema: &Schema, group_by: &PhysicalGroupBy) -> Result<SchemaRef> {
928-
Ok(Arc::new(Schema::new(group_by.group_fields(input_schema)?)))
929-
}
930-
931931
/// Determines the lexical ordering requirement for an aggregate expression.
932932
///
933933
/// # Parameters

datafusion/physical-plan/src/aggregates/row_hash.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use std::vec;
2424
use crate::aggregates::group_values::{new_group_values, GroupValues};
2525
use crate::aggregates::order::GroupOrderingFull;
2626
use crate::aggregates::{
27-
create_schema, evaluate_group_by, evaluate_many, evaluate_optional, group_schema,
28-
AggregateMode, PhysicalGroupBy,
27+
create_schema, evaluate_group_by, evaluate_many, evaluate_optional, AggregateMode,
28+
PhysicalGroupBy,
2929
};
3030
use crate::metrics::{BaselineMetrics, MetricBuilder, RecordOutput};
3131
use crate::sorts::sort::sort_batch;
@@ -489,7 +489,7 @@ impl GroupedHashAggregateStream {
489489
.map(create_group_accumulator)
490490
.collect::<Result<_>>()?;
491491

492-
let group_schema = group_schema(&agg.input().schema(), &agg_group_by)?;
492+
let group_schema = agg_group_by.group_schema(&agg.input().schema())?;
493493

494494
// fix https://github.com/apache/datafusion/issues/13949
495495
// Builds a **partial aggregation** schema by combining the group columns and

0 commit comments

Comments
 (0)