Apache DataFusion SQL Query Engine
Removed Arc wrapping for AggregateFunctionExpr (#12353)
Athul T Rf5c47fa274d5
diff --git a/datafusion/core/src/physical_optimizer/update_aggr_exprs.rs b/datafusion/core/src/physical_optimizer/update_aggr_exprs.rsindex a2726d62e9..8b5084c67e 100644--- a/datafusion/core/src/physical_optimizer/update_aggr_exprs.rs+++ b/datafusion/core/src/physical_optimizer/update_aggr_exprs.rs@@ -118,7 +118,7 @@ impl PhysicalOptimizerRule for OptimizeAggregateOrder {////// # Parameters///-/// * `aggr_exprs` - A vector of `Arc<AggregateFunctionExpr>` representing the+/// * `aggr_exprs` - A vector of `AggregateFunctionExpr` representing the/// aggregate expressions to be optimized./// * `prefix_requirement` - An array slice representing the ordering/// requirements preceding the aggregate expressions.@@ -131,10 +131,10 @@ impl PhysicalOptimizerRule for OptimizeAggregateOrder {/// successfully. Any errors occurring during the conversion process are/// passed through.fn try_convert_aggregate_if_better(- aggr_exprs: Vec<Arc<AggregateFunctionExpr>>,+ aggr_exprs: Vec<AggregateFunctionExpr>,prefix_requirement: &[PhysicalSortRequirement],eq_properties: &EquivalenceProperties,-) -> Result<Vec<Arc<AggregateFunctionExpr>>> {+) -> Result<Vec<AggregateFunctionExpr>> {aggr_exprs.into_iter().map(|aggr_expr| {diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rsindex 82405dd98e..cc35255dfe 100644--- a/datafusion/core/src/physical_planner.rs+++ b/datafusion/core/src/physical_planner.rs@@ -1541,7 +1541,7 @@ pub fn create_window_expr(}type AggregateExprWithOptionalArgs = (- Arc<AggregateFunctionExpr>,+ AggregateFunctionExpr,// The filter clause, if anyOption<Arc<dyn PhysicalExpr>>,// Ordering requirements, if anydiff --git a/datafusion/core/src/test_util/mod.rs b/datafusion/core/src/test_util/mod.rsindex dd8b697666..edccb3844c 100644--- a/datafusion/core/src/test_util/mod.rs+++ b/datafusion/core/src/test_util/mod.rs@@ -427,7 +427,7 @@ impl TestAggregate {}/// Return appropriate expr depending if COUNT is for col or table (*)- pub fn count_expr(&self, schema: &Schema) -> Arc<AggregateFunctionExpr> {+ pub fn count_expr(&self, schema: &Schema) -> AggregateFunctionExpr {AggregateExprBuilder::new(count_udaf(), vec![self.column()]).schema(Arc::new(schema.clone())).alias(self.column_name())diff --git a/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs b/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rsindex 5152afa6c0..24e46b3ad9 100644--- a/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs+++ b/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs@@ -84,7 +84,7 @@ fn parquet_exec(schema: &SchemaRef) -> Arc<ParquetExec> {fn partial_aggregate_exec(input: Arc<dyn ExecutionPlan>,group_by: PhysicalGroupBy,- aggr_expr: Vec<Arc<AggregateFunctionExpr>>,+ aggr_expr: Vec<AggregateFunctionExpr>,) -> Arc<dyn ExecutionPlan> {let schema = input.schema();let n_aggr = aggr_expr.len();@@ -104,7 +104,7 @@ fn partial_aggregate_exec(fn final_aggregate_exec(input: Arc<dyn ExecutionPlan>,group_by: PhysicalGroupBy,- aggr_expr: Vec<Arc<AggregateFunctionExpr>>,+ aggr_expr: Vec<AggregateFunctionExpr>,) -> Arc<dyn ExecutionPlan> {let schema = input.schema();let n_aggr = aggr_expr.len();@@ -130,7 +130,7 @@ fn count_expr(expr: Arc<dyn PhysicalExpr>,name: &str,schema: &Schema,-) -> Arc<AggregateFunctionExpr> {+) -> AggregateFunctionExpr {AggregateExprBuilder::new(count_udaf(), vec![expr]).schema(Arc::new(schema.clone())).alias(name)diff --git a/datafusion/physical-expr/src/aggregate.rs b/datafusion/physical-expr/src/aggregate.rsindex d62dc27ece..866596d0b6 100644--- a/datafusion/physical-expr/src/aggregate.rs+++ b/datafusion/physical-expr/src/aggregate.rs@@ -88,7 +88,7 @@ impl AggregateExprBuilder {}}- pub fn build(self) -> Result<Arc<AggregateFunctionExpr>> {+ pub fn build(self) -> Result<AggregateFunctionExpr> {let Self {fun,args,@@ -132,7 +132,7 @@ impl AggregateExprBuilder {Some(alias) => alias,};- Ok(Arc::new(AggregateFunctionExpr {+ Ok(AggregateFunctionExpr {fun: Arc::unwrap_or_clone(fun),args,data_type,@@ -145,7 +145,7 @@ impl AggregateExprBuilder {input_types: input_exprs_types,is_reversed,is_nullable,- }))+ })}pub fn alias(mut self, alias: impl Into<String>) -> Self {@@ -328,9 +328,9 @@ impl AggregateFunctionExpr {/// not implement the method, returns an error. Order insensitive and hard/// requirement aggregators return `Ok(None)`.pub fn with_beneficial_ordering(- self: Arc<Self>,+ self,beneficial_ordering: bool,- ) -> Result<Option<Arc<AggregateFunctionExpr>>> {+ ) -> Result<Option<AggregateFunctionExpr>> {let Some(updated_fn) = self.fun.clone()@@ -457,10 +457,10 @@ impl AggregateFunctionExpr {/// Typically the "reverse" expression is itself (e.g. SUM, COUNT)./// For aggregates that do not support calculation in reverse,/// returns None (which is the default value).- pub fn reverse_expr(&self) -> Option<Arc<AggregateFunctionExpr>> {+ pub fn reverse_expr(&self) -> Option<AggregateFunctionExpr> {match self.fun.reverse_udf() {ReversedUDAF::NotSupported => None,- ReversedUDAF::Identical => Some(Arc::new(self.clone())),+ ReversedUDAF::Identical => Some(self.clone()),ReversedUDAF::Reversed(reverse_udf) => {let reverse_ordering_req = reverse_order_bys(&self.ordering_req);let mut name = self.name().to_string();@@ -507,7 +507,7 @@ impl AggregateFunctionExpr {&self,_args: Vec<Arc<dyn PhysicalExpr>>,_order_by_exprs: Vec<Arc<dyn PhysicalExpr>>,- ) -> Option<Arc<AggregateFunctionExpr>> {+ ) -> Option<AggregateFunctionExpr> {None}diff --git a/datafusion/physical-expr/src/window/aggregate.rs b/datafusion/physical-expr/src/window/aggregate.rsindex 1cc08a4e99..d012fef93b 100644--- a/datafusion/physical-expr/src/window/aggregate.rs+++ b/datafusion/physical-expr/src/window/aggregate.rs@@ -41,7 +41,7 @@ use crate::{expressions::PhysicalSortExpr, reverse_order_bys, PhysicalExpr};/// See comments on [`WindowExpr`] for more details.#[derive(Debug)]pub struct PlainAggregateWindowExpr {- aggregate: Arc<AggregateFunctionExpr>,+ aggregate: AggregateFunctionExpr,partition_by: Vec<Arc<dyn PhysicalExpr>>,order_by: Vec<PhysicalSortExpr>,window_frame: Arc<WindowFrame>,@@ -50,7 +50,7 @@ pub struct PlainAggregateWindowExpr {impl PlainAggregateWindowExpr {/// Create a new aggregate window function expressionpub fn new(- aggregate: Arc<AggregateFunctionExpr>,+ aggregate: AggregateFunctionExpr,partition_by: &[Arc<dyn PhysicalExpr>],order_by: &[PhysicalSortExpr],window_frame: Arc<WindowFrame>,@@ -64,7 +64,7 @@ impl PlainAggregateWindowExpr {}/// Get aggregate expr of AggregateWindowExpr- pub fn get_aggregate_expr(&self) -> &Arc<AggregateFunctionExpr> {+ pub fn get_aggregate_expr(&self) -> &AggregateFunctionExpr {&self.aggregate}}diff --git a/datafusion/physical-expr/src/window/sliding_aggregate.rs b/datafusion/physical-expr/src/window/sliding_aggregate.rsindex b3848e15ee..143d59eb44 100644--- a/datafusion/physical-expr/src/window/sliding_aggregate.rs+++ b/datafusion/physical-expr/src/window/sliding_aggregate.rs@@ -41,7 +41,7 @@ use crate::{expressions::PhysicalSortExpr, reverse_order_bys, PhysicalExpr};/// See comments on [`WindowExpr`] for more details.#[derive(Debug)]pub struct SlidingAggregateWindowExpr {- aggregate: Arc<AggregateFunctionExpr>,+ aggregate: AggregateFunctionExpr,partition_by: Vec<Arc<dyn PhysicalExpr>>,order_by: Vec<PhysicalSortExpr>,window_frame: Arc<WindowFrame>,@@ -50,7 +50,7 @@ pub struct SlidingAggregateWindowExpr {impl SlidingAggregateWindowExpr {/// Create a new (sliding) aggregate window function expression.pub fn new(- aggregate: Arc<AggregateFunctionExpr>,+ aggregate: AggregateFunctionExpr,partition_by: &[Arc<dyn PhysicalExpr>],order_by: &[PhysicalSortExpr],window_frame: Arc<WindowFrame>,@@ -64,7 +64,7 @@ impl SlidingAggregateWindowExpr {}/// Get the [AggregateFunctionExpr] of this object.- pub fn get_aggregate_expr(&self) -> &Arc<AggregateFunctionExpr> {+ pub fn get_aggregate_expr(&self) -> &AggregateFunctionExpr {&self.aggregate}}diff --git a/datafusion/physical-optimizer/src/combine_partial_final_agg.rs b/datafusion/physical-optimizer/src/combine_partial_final_agg.rsindex 12ff13f8f6..67e40c9b50 100644--- a/datafusion/physical-optimizer/src/combine_partial_final_agg.rs+++ b/datafusion/physical-optimizer/src/combine_partial_final_agg.rs@@ -125,7 +125,7 @@ impl PhysicalOptimizerRule for CombinePartialFinalAggregate {type GroupExprsRef<'a> = (&'a PhysicalGroupBy,- &'a [Arc<AggregateFunctionExpr>],+ &'a [AggregateFunctionExpr],&'a [Option<Arc<dyn PhysicalExpr>>],);diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rsindex bf6d71308c..ad0e43631a 100644--- a/datafusion/physical-plan/src/aggregates/mod.rs+++ b/datafusion/physical-plan/src/aggregates/mod.rs@@ -262,7 +262,7 @@ pub struct AggregateExec {/// Group by expressionsgroup_by: PhysicalGroupBy,/// Aggregate expressions- aggr_expr: Vec<Arc<AggregateFunctionExpr>>,+ aggr_expr: Vec<AggregateFunctionExpr>,/// FILTER (WHERE clause) expression for each aggregate expressionfilter_expr: Vec<Option<Arc<dyn PhysicalExpr>>>,/// Set if the output of this aggregation is truncated by a upstream sort/limit clause@@ -289,10 +289,7 @@ impl AggregateExec {/// Function used in `OptimizeAggregateOrder` optimizer rule,/// where we need parts of the new value, others cloned from the old one/// Rewrites aggregate exec with new aggregate expressions.- pub fn with_new_aggr_exprs(- &self,- aggr_expr: Vec<Arc<AggregateFunctionExpr>>,- ) -> Self {+ pub fn with_new_aggr_exprs(&self, aggr_expr: Vec<AggregateFunctionExpr>) -> Self {Self {aggr_expr,// clone the rest of the fields@@ -318,7 +315,7 @@ impl AggregateExec {pub fn try_new(mode: AggregateMode,group_by: PhysicalGroupBy,- aggr_expr: Vec<Arc<AggregateFunctionExpr>>,+ aggr_expr: Vec<AggregateFunctionExpr>,filter_expr: Vec<Option<Arc<dyn PhysicalExpr>>>,input: Arc<dyn ExecutionPlan>,input_schema: SchemaRef,@@ -355,7 +352,7 @@ impl AggregateExec {fn try_new_with_schema(mode: AggregateMode,group_by: PhysicalGroupBy,- mut aggr_expr: Vec<Arc<AggregateFunctionExpr>>,+ mut aggr_expr: Vec<AggregateFunctionExpr>,filter_expr: Vec<Option<Arc<dyn PhysicalExpr>>>,input: Arc<dyn ExecutionPlan>,input_schema: SchemaRef,@@ -463,7 +460,7 @@ impl AggregateExec {}/// Aggregate expressions- pub fn aggr_expr(&self) -> &[Arc<AggregateFunctionExpr>] {+ pub fn aggr_expr(&self) -> &[AggregateFunctionExpr] {&self.aggr_expr}@@ -790,7 +787,7 @@ impl ExecutionPlan for AggregateExec {fn create_schema(input_schema: &Schema,group_expr: &[(Arc<dyn PhysicalExpr>, String)],- aggr_expr: &[Arc<AggregateFunctionExpr>],+ aggr_expr: &[AggregateFunctionExpr],group_expr_nullable: Vec<bool>,mode: AggregateMode,) -> Result<Schema> {@@ -836,7 +833,7 @@ fn group_schema(schema: &Schema, group_count: usize) -> SchemaRef {////// # Parameters///-/// - `aggr_expr`: A reference to an `Arc<AggregateFunctionExpr>` representing the+/// - `aggr_expr`: A reference to an `AggregateFunctionExpr` representing the/// aggregate expression./// - `group_by`: A reference to a `PhysicalGroupBy` instance representing the/// physical GROUP BY expression.@@ -848,7 +845,7 @@ fn group_schema(schema: &Schema, group_count: usize) -> SchemaRef {/// A `LexOrdering` instance indicating the lexical ordering requirement for/// the aggregate expression.fn get_aggregate_expr_req(- aggr_expr: &Arc<AggregateFunctionExpr>,+ aggr_expr: &AggregateFunctionExpr,group_by: &PhysicalGroupBy,agg_mode: &AggregateMode,) -> LexOrdering {@@ -896,7 +893,7 @@ fn get_aggregate_expr_req(/// the aggregator requirement is incompatible.fn finer_ordering(existing_req: &LexOrdering,- aggr_expr: &Arc<AggregateFunctionExpr>,+ aggr_expr: &AggregateFunctionExpr,group_by: &PhysicalGroupBy,eq_properties: &EquivalenceProperties,agg_mode: &AggregateMode,@@ -914,7 +911,7 @@ pub fn concat_slices<T: Clone>(lhs: &[T], rhs: &[T]) -> Vec<T> {////// # Parameters///-/// - `aggr_exprs`: A slice of `Arc<AggregateFunctionExpr>` containing all the+/// - `aggr_exprs`: A slice of `AggregateFunctionExpr` containing all the/// aggregate expressions./// - `group_by`: A reference to a `PhysicalGroupBy` instance representing the/// physical GROUP BY expression.@@ -928,7 +925,7 @@ pub fn concat_slices<T: Clone>(lhs: &[T], rhs: &[T]) -> Vec<T> {/// A `LexRequirement` instance, which is the requirement that satisfies all the/// aggregate requirements. Returns an error in case of conflicting requirements.pub fn get_finer_aggregate_exprs_requirement(- aggr_exprs: &mut [Arc<AggregateFunctionExpr>],+ aggr_exprs: &mut [AggregateFunctionExpr],group_by: &PhysicalGroupBy,eq_properties: &EquivalenceProperties,agg_mode: &AggregateMode,@@ -1002,7 +999,7 @@ pub fn get_finer_aggregate_exprs_requirement(/// * Partial: AggregateFunctionExpr::expressions/// * Final: columns of `AggregateFunctionExpr::state_fields()`pub fn aggregate_expressions(- aggr_expr: &[Arc<AggregateFunctionExpr>],+ aggr_expr: &[AggregateFunctionExpr],mode: &AggregateMode,col_idx_base: usize,) -> Result<Vec<Vec<Arc<dyn PhysicalExpr>>>> {@@ -1043,7 +1040,7 @@ pub fn aggregate_expressions(/// `index_base` is the starting physical column index for the next expanded state field.fn merge_expressions(index_base: usize,- expr: &Arc<AggregateFunctionExpr>,+ expr: &AggregateFunctionExpr,) -> Result<Vec<Arc<dyn PhysicalExpr>>> {expr.state_fields().map(|fields| {fields@@ -1057,7 +1054,7 @@ fn merge_expressions(pub type AccumulatorItem = Box<dyn Accumulator>;pub fn create_accumulators(- aggr_expr: &[Arc<AggregateFunctionExpr>],+ aggr_expr: &[AggregateFunctionExpr],) -> Result<Vec<AccumulatorItem>> {aggr_expr.iter()@@ -1497,12 +1494,13 @@ mod tests {groups: vec![vec![false]],};- let aggregates: Vec<Arc<AggregateFunctionExpr>> = vec![- AggregateExprBuilder::new(avg_udaf(), vec![col("b", &input_schema)?])- .schema(Arc::clone(&input_schema))- .alias("AVG(b)")- .build()?,- ];+ let aggregates: Vec<AggregateFunctionExpr> =+ vec![+ AggregateExprBuilder::new(avg_udaf(), vec![col("b", &input_schema)?])+ .schema(Arc::clone(&input_schema))+ .alias("AVG(b)")+ .build()?,+ ];let task_ctx = if spill {// set to an appropriate value to trigger spill@@ -1793,7 +1791,7 @@ mod tests {}// Median(a)- fn test_median_agg_expr(schema: SchemaRef) -> Result<Arc<AggregateFunctionExpr>> {+ fn test_median_agg_expr(schema: SchemaRef) -> Result<AggregateFunctionExpr> {AggregateExprBuilder::new(median_udaf(), vec![col("a", &schema)?]).schema(schema).alias("MEDIAN(a)")@@ -1819,16 +1817,17 @@ mod tests {};// something that allocates within the aggregator- let aggregates_v0: Vec<Arc<AggregateFunctionExpr>> =+ let aggregates_v0: Vec<AggregateFunctionExpr> =vec![test_median_agg_expr(Arc::clone(&input_schema))?];// use fast-path in `row_hash.rs`.- let aggregates_v2: Vec<Arc<AggregateFunctionExpr>> = vec![- AggregateExprBuilder::new(avg_udaf(), vec![col("b", &input_schema)?])- .schema(Arc::clone(&input_schema))- .alias("AVG(b)")- .build()?,- ];+ let aggregates_v2: Vec<AggregateFunctionExpr> =+ vec![+ AggregateExprBuilder::new(avg_udaf(), vec![col("b", &input_schema)?])+ .schema(Arc::clone(&input_schema))+ .alias("AVG(b)")+ .build()?,+ ];for (version, groups, aggregates) in [(0, groups_none, aggregates_v0),@@ -1882,12 +1881,13 @@ mod tests {let groups = PhysicalGroupBy::default();- let aggregates: Vec<Arc<AggregateFunctionExpr>> = vec![- AggregateExprBuilder::new(avg_udaf(), vec![col("a", &schema)?])- .schema(Arc::clone(&schema))- .alias("AVG(a)")- .build()?,- ];+ let aggregates: Vec<AggregateFunctionExpr> =+ vec![+ AggregateExprBuilder::new(avg_udaf(), vec![col("a", &schema)?])+ .schema(Arc::clone(&schema))+ .alias("AVG(a)")+ .build()?,+ ];let blocking_exec = Arc::new(BlockingExec::new(Arc::clone(&schema), 1));let refs = blocking_exec.refs();@@ -1921,12 +1921,13 @@ mod tests {let groups =PhysicalGroupBy::new_single(vec![(col("a", &schema)?, "a".to_string())]);- let aggregates: Vec<Arc<AggregateFunctionExpr>> = vec![- AggregateExprBuilder::new(avg_udaf(), vec![col("b", &schema)?])- .schema(Arc::clone(&schema))- .alias("AVG(b)")- .build()?,- ];+ let aggregates: Vec<AggregateFunctionExpr> =+ vec![+ AggregateExprBuilder::new(avg_udaf(), vec![col("b", &schema)?])+ .schema(Arc::clone(&schema))+ .alias("AVG(b)")+ .build()?,+ ];let blocking_exec = Arc::new(BlockingExec::new(Arc::clone(&schema), 1));let refs = blocking_exec.refs();@@ -1971,7 +1972,7 @@ mod tests {fn test_first_value_agg_expr(schema: &Schema,sort_options: SortOptions,- ) -> Result<Arc<AggregateFunctionExpr>> {+ ) -> Result<AggregateFunctionExpr> {let ordering_req = [PhysicalSortExpr {expr: col("b", schema)?,options: sort_options,@@ -1989,7 +1990,7 @@ mod tests {fn test_last_value_agg_expr(schema: &Schema,sort_options: SortOptions,- ) -> Result<Arc<AggregateFunctionExpr>> {+ ) -> Result<AggregateFunctionExpr> {let ordering_req = [PhysicalSortExpr {expr: col("b", schema)?,options: sort_options,@@ -2044,7 +2045,7 @@ mod tests {descending: false,nulls_first: false,};- let aggregates: Vec<Arc<AggregateFunctionExpr>> = if is_first_acc {+ let aggregates: Vec<AggregateFunctionExpr> = if is_first_acc {vec![test_first_value_agg_expr(&schema, sort_options)?]} else {vec![test_last_value_agg_expr(&schema, sort_options)?]@@ -2209,7 +2210,7 @@ mod tests {};let groups = PhysicalGroupBy::new_single(vec![(col_a, "a".to_string())]);- let aggregates: Vec<Arc<AggregateFunctionExpr>> = vec![+ let aggregates: Vec<AggregateFunctionExpr> = vec![test_first_value_agg_expr(&schema, option_desc)?,test_last_value_agg_expr(&schema, option_desc)?,];@@ -2267,7 +2268,7 @@ mod tests {],);- let aggregates: Vec<Arc<AggregateFunctionExpr>> =+ let aggregates: Vec<AggregateFunctionExpr> =vec![AggregateExprBuilder::new(count_udaf(), vec![lit(1)]).schema(Arc::clone(&schema)).alias("1")diff --git a/datafusion/physical-plan/src/aggregates/row_hash.rs b/datafusion/physical-plan/src/aggregates/row_hash.rsindex c38137994d..fd2d26d9b4 100644--- a/datafusion/physical-plan/src/aggregates/row_hash.rs+++ b/datafusion/physical-plan/src/aggregates/row_hash.rs@@ -578,7 +578,7 @@ impl GroupedHashAggregateStream {/// that is supported by the aggregate, or a/// [`GroupsAccumulatorAdapter`] if not.pub(crate) fn create_group_accumulator(- agg_expr: &Arc<AggregateFunctionExpr>,+ agg_expr: &AggregateFunctionExpr,) -> Result<Box<dyn GroupsAccumulator>> {if agg_expr.groups_accumulator_supported() {agg_expr.create_groups_accumulator()@@ -588,7 +588,7 @@ pub(crate) fn create_group_accumulator("Creating GroupsAccumulatorAdapter for {}: {agg_expr:?}",agg_expr.name());- let agg_expr_captured = Arc::clone(agg_expr);+ let agg_expr_captured = agg_expr.clone();let factory = move || agg_expr_captured.create_accumulator();Ok(Box::new(GroupsAccumulatorAdapter::new(factory)))}diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rsindex 56823e6dec..0275cd2441 100644--- a/datafusion/physical-plan/src/windows/mod.rs+++ b/datafusion/physical-plan/src/windows/mod.rs@@ -141,7 +141,7 @@ fn window_expr_from_aggregate_expr(partition_by: &[Arc<dyn PhysicalExpr>],order_by: &[PhysicalSortExpr],window_frame: Arc<WindowFrame>,- aggregate: Arc<AggregateFunctionExpr>,+ aggregate: AggregateFunctionExpr,) -> Arc<dyn WindowExpr> {// Is there a potentially unlimited sized window frame?let unbounded_window = window_frame.start_bound.is_unbounded();diff --git a/datafusion/proto/src/physical_plan/mod.rs b/datafusion/proto/src/physical_plan/mod.rsindex 74b6073a41..e1cc37091b 100644--- a/datafusion/proto/src/physical_plan/mod.rs+++ b/datafusion/proto/src/physical_plan/mod.rs@@ -481,7 +481,7 @@ impl AsExecutionPlan for protobuf::PhysicalPlanNode {}).collect::<Result<Vec<_>, _>>()?;- let physical_aggr_expr: Vec<Arc<AggregateFunctionExpr>> = hash_agg+ let physical_aggr_expr: Vec<AggregateFunctionExpr> = hash_agg.aggr_expr.iter().zip(hash_agg.aggr_expr_name.iter())diff --git a/datafusion/proto/src/physical_plan/to_proto.rs b/datafusion/proto/src/physical_plan/to_proto.rsindex 25be7de61c..6981c77228 100644--- a/datafusion/proto/src/physical_plan/to_proto.rs+++ b/datafusion/proto/src/physical_plan/to_proto.rs@@ -49,7 +49,7 @@ use crate::protobuf::{use super::PhysicalExtensionCodec;pub fn serialize_physical_aggr_expr(- aggr_expr: Arc<AggregateFunctionExpr>,+ aggr_expr: AggregateFunctionExpr,codec: &dyn PhysicalExtensionCodec,) -> Result<protobuf::PhysicalExprNode> {let expressions = serialize_physical_exprs(&aggr_expr.expressions(), codec)?;@@ -171,7 +171,7 @@ pub fn serialize_physical_window_expr(expr.downcast_ref::<PlainAggregateWindowExpr>(){serialize_physical_window_aggr_expr(- plain_aggr_window_expr.get_aggregate_expr().as_ref(),+ plain_aggr_window_expr.get_aggregate_expr(),window_frame,codec,)?@@ -179,7 +179,7 @@ pub fn serialize_physical_window_expr(expr.downcast_ref::<SlidingAggregateWindowExpr>(){serialize_physical_window_aggr_expr(- sliding_aggr_window_expr.get_aggregate_expr().as_ref(),+ sliding_aggr_window_expr.get_aggregate_expr(),window_frame,codec,)?diff --git a/datafusion/proto/tests/cases/roundtrip_physical_plan.rs b/datafusion/proto/tests/cases/roundtrip_physical_plan.rsindex 97d65ba871..58f6015ee3 100644--- a/datafusion/proto/tests/cases/roundtrip_physical_plan.rs+++ b/datafusion/proto/tests/cases/roundtrip_physical_plan.rs@@ -364,7 +364,7 @@ fn rountrip_aggregate() -> Result<()> {.alias("NTH_VALUE(b, 1)").build()?;- let test_cases: Vec<Vec<Arc<AggregateFunctionExpr>>> = vec![+ let test_cases: Vec<Vec<AggregateFunctionExpr>> = vec![// AVGvec![avg_expr],// NTH_VALUE@@ -397,7 +397,7 @@ fn rountrip_aggregate_with_limit() -> Result<()> {let groups: Vec<(Arc<dyn PhysicalExpr>, String)> =vec![(col("a", &schema)?, "unused".to_string())];- let aggregates: Vec<Arc<AggregateFunctionExpr>> =+ let aggregates: Vec<AggregateFunctionExpr> =vec![AggregateExprBuilder::new(avg_udaf(), vec![col("b", &schema)?]).schema(Arc::clone(&schema))@@ -426,7 +426,7 @@ fn rountrip_aggregate_with_approx_pencentile_cont() -> Result<()> {let groups: Vec<(Arc<dyn PhysicalExpr>, String)> =vec![(col("a", &schema)?, "unused".to_string())];- let aggregates: Vec<Arc<AggregateFunctionExpr>> = vec![AggregateExprBuilder::new(+ let aggregates: Vec<AggregateFunctionExpr> = vec![AggregateExprBuilder::new(approx_percentile_cont_udaf(),vec![col("b", &schema)?, lit(0.5)],)@@ -461,7 +461,7 @@ fn rountrip_aggregate_with_sort() -> Result<()> {},}];- let aggregates: Vec<Arc<AggregateFunctionExpr>> =+ let aggregates: Vec<AggregateFunctionExpr> =vec![AggregateExprBuilder::new(array_agg_udaf(), vec![col("b", &schema)?]).schema(Arc::clone(&schema))@@ -528,7 +528,7 @@ fn roundtrip_aggregate_udaf() -> Result<()> {let groups: Vec<(Arc<dyn PhysicalExpr>, String)> =vec![(col("a", &schema)?, "unused".to_string())];- let aggregates: Vec<Arc<AggregateFunctionExpr>> =+ let aggregates: Vec<AggregateFunctionExpr> =vec![AggregateExprBuilder::new(Arc::new(udaf), vec![col("b", &schema)?]).schema(Arc::clone(&schema))