@@ -544,11 +544,11 @@ pub struct AggregateExec {
544544 /// Aggregation mode (full, partial)
545545 mode : AggregateMode ,
546546 /// Group by expressions
547- group_by : PhysicalGroupBy ,
547+ group_by : Arc < PhysicalGroupBy > ,
548548 /// Aggregate expressions
549- aggr_expr : Vec < Arc < AggregateFunctionExpr > > ,
549+ aggr_expr : Arc < [ Arc < AggregateFunctionExpr > ] > ,
550550 /// FILTER (WHERE clause) expression for each aggregate expression
551- filter_expr : Vec < Option < Arc < dyn PhysicalExpr > > > ,
551+ filter_expr : Arc < [ Option < Arc < dyn PhysicalExpr > > ] > ,
552552 /// Configuration for limit-based optimizations
553553 limit_options : Option < LimitOptions > ,
554554 /// Input plan, could be a partial aggregate or the input to the aggregate
@@ -582,18 +582,18 @@ impl AggregateExec {
582582 /// Rewrites aggregate exec with new aggregate expressions.
583583 pub fn with_new_aggr_exprs (
584584 & self ,
585- aggr_expr : Vec < Arc < AggregateFunctionExpr > > ,
585+ aggr_expr : impl Into < Arc < [ Arc < AggregateFunctionExpr > ] > > ,
586586 ) -> Self {
587587 Self {
588- aggr_expr,
588+ aggr_expr : aggr_expr . into ( ) ,
589589 // clone the rest of the fields
590590 required_input_ordering : self . required_input_ordering . clone ( ) ,
591591 metrics : ExecutionPlanMetricsSet :: new ( ) ,
592592 input_order_mode : self . input_order_mode . clone ( ) ,
593593 cache : self . cache . clone ( ) ,
594594 mode : self . mode ,
595- group_by : self . group_by . clone ( ) ,
596- filter_expr : self . filter_expr . clone ( ) ,
595+ group_by : Arc :: clone ( & self . group_by ) ,
596+ filter_expr : Arc :: clone ( & self . filter_expr ) ,
597597 limit_options : self . limit_options ,
598598 input : Arc :: clone ( & self . input ) ,
599599 schema : Arc :: clone ( & self . schema ) ,
@@ -612,9 +612,9 @@ impl AggregateExec {
612612 input_order_mode : self . input_order_mode . clone ( ) ,
613613 cache : self . cache . clone ( ) ,
614614 mode : self . mode ,
615- group_by : self . group_by . clone ( ) ,
616- aggr_expr : self . aggr_expr . clone ( ) ,
617- filter_expr : self . filter_expr . clone ( ) ,
615+ group_by : Arc :: clone ( & self . group_by ) ,
616+ aggr_expr : Arc :: clone ( & self . aggr_expr ) ,
617+ filter_expr : Arc :: clone ( & self . filter_expr ) ,
618618 input : Arc :: clone ( & self . input ) ,
619619 schema : Arc :: clone ( & self . schema ) ,
620620 input_schema : Arc :: clone ( & self . input_schema ) ,
@@ -629,12 +629,13 @@ impl AggregateExec {
629629 /// Create a new hash aggregate execution plan
630630 pub fn try_new (
631631 mode : AggregateMode ,
632- group_by : PhysicalGroupBy ,
632+ group_by : impl Into < Arc < PhysicalGroupBy > > ,
633633 aggr_expr : Vec < Arc < AggregateFunctionExpr > > ,
634634 filter_expr : Vec < Option < Arc < dyn PhysicalExpr > > > ,
635635 input : Arc < dyn ExecutionPlan > ,
636636 input_schema : SchemaRef ,
637637 ) -> Result < Self > {
638+ let group_by = group_by. into ( ) ;
638639 let schema = create_schema ( & input. schema ( ) , & group_by, & aggr_expr, mode) ?;
639640
640641 let schema = Arc :: new ( schema) ;
@@ -659,13 +660,16 @@ impl AggregateExec {
659660 /// the schema in such cases.
660661 fn try_new_with_schema (
661662 mode : AggregateMode ,
662- group_by : PhysicalGroupBy ,
663+ group_by : impl Into < Arc < PhysicalGroupBy > > ,
663664 mut aggr_expr : Vec < Arc < AggregateFunctionExpr > > ,
664- filter_expr : Vec < Option < Arc < dyn PhysicalExpr > > > ,
665+ filter_expr : impl Into < Arc < [ Option < Arc < dyn PhysicalExpr > > ] > > ,
665666 input : Arc < dyn ExecutionPlan > ,
666667 input_schema : SchemaRef ,
667668 schema : SchemaRef ,
668669 ) -> Result < Self > {
670+ let group_by = group_by. into ( ) ;
671+ let filter_expr = filter_expr. into ( ) ;
672+
669673 // Make sure arguments are consistent in size
670674 assert_eq_or_internal_err ! (
671675 aggr_expr. len( ) ,
@@ -732,13 +736,13 @@ impl AggregateExec {
732736 & group_expr_mapping,
733737 & mode,
734738 & input_order_mode,
735- aggr_expr. as_slice ( ) ,
739+ aggr_expr. as_ref ( ) ,
736740 ) ?;
737741
738742 let mut exec = AggregateExec {
739743 mode,
740744 group_by,
741- aggr_expr,
745+ aggr_expr : aggr_expr . into ( ) ,
742746 filter_expr,
743747 input,
744748 schema,
@@ -1287,9 +1291,9 @@ impl ExecutionPlan for AggregateExec {
12871291 ) -> Result < Arc < dyn ExecutionPlan > > {
12881292 let mut me = AggregateExec :: try_new_with_schema (
12891293 self . mode ,
1290- self . group_by . clone ( ) ,
1291- self . aggr_expr . clone ( ) ,
1292- self . filter_expr . clone ( ) ,
1294+ Arc :: clone ( & self . group_by ) ,
1295+ self . aggr_expr . to_vec ( ) ,
1296+ Arc :: clone ( & self . filter_expr ) ,
12931297 Arc :: clone ( & children[ 0 ] ) ,
12941298 Arc :: clone ( & self . input_schema ) ,
12951299 Arc :: clone ( & self . schema ) ,
0 commit comments