Skip to content

Commit 461e842

Browse files
committed
Removed Arc wrapping for AggregateFunctionExpr
1 parent 650dfdc commit 461e842

File tree

13 files changed

+84
-83
lines changed

13 files changed

+84
-83
lines changed

datafusion/core/src/physical_optimizer/combine_partial_final_agg.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl PhysicalOptimizerRule for CombinePartialFinalAggregate {
123123

124124
type GroupExprsRef<'a> = (
125125
&'a PhysicalGroupBy,
126-
&'a [Arc<AggregateFunctionExpr>],
126+
&'a [AggregateFunctionExpr],
127127
&'a [Option<Arc<dyn PhysicalExpr>>],
128128
);
129129

@@ -225,7 +225,7 @@ mod tests {
225225
fn partial_aggregate_exec(
226226
input: Arc<dyn ExecutionPlan>,
227227
group_by: PhysicalGroupBy,
228-
aggr_expr: Vec<Arc<AggregateFunctionExpr>>,
228+
aggr_expr: Vec<AggregateFunctionExpr>,
229229
) -> Arc<dyn ExecutionPlan> {
230230
let schema = input.schema();
231231
let n_aggr = aggr_expr.len();
@@ -245,7 +245,7 @@ mod tests {
245245
fn final_aggregate_exec(
246246
input: Arc<dyn ExecutionPlan>,
247247
group_by: PhysicalGroupBy,
248-
aggr_expr: Vec<Arc<AggregateFunctionExpr>>,
248+
aggr_expr: Vec<AggregateFunctionExpr>,
249249
) -> Arc<dyn ExecutionPlan> {
250250
let schema = input.schema();
251251
let n_aggr = aggr_expr.len();
@@ -273,7 +273,7 @@ mod tests {
273273
expr: Arc<dyn PhysicalExpr>,
274274
name: &str,
275275
schema: &Schema,
276-
) -> Arc<AggregateFunctionExpr> {
276+
) -> AggregateFunctionExpr {
277277
AggregateExprBuilder::new(count_udaf(), vec![expr])
278278
.schema(Arc::new(schema.clone()))
279279
.alias(name)

datafusion/core/src/physical_optimizer/update_aggr_exprs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl PhysicalOptimizerRule for OptimizeAggregateOrder {
118118
///
119119
/// # Parameters
120120
///
121-
/// * `aggr_exprs` - A vector of `Arc<AggregateFunctionExpr>` representing the
121+
/// * `aggr_exprs` - A vector of `AggregateFunctionExpr` representing the
122122
/// aggregate expressions to be optimized.
123123
/// * `prefix_requirement` - An array slice representing the ordering
124124
/// requirements preceding the aggregate expressions.
@@ -131,10 +131,10 @@ impl PhysicalOptimizerRule for OptimizeAggregateOrder {
131131
/// successfully. Any errors occurring during the conversion process are
132132
/// passed through.
133133
fn try_convert_aggregate_if_better(
134-
aggr_exprs: Vec<Arc<AggregateFunctionExpr>>,
134+
aggr_exprs: Vec<AggregateFunctionExpr>,
135135
prefix_requirement: &[PhysicalSortRequirement],
136136
eq_properties: &EquivalenceProperties,
137-
) -> Result<Vec<Arc<AggregateFunctionExpr>>> {
137+
) -> Result<Vec<AggregateFunctionExpr>> {
138138
aggr_exprs
139139
.into_iter()
140140
.map(|aggr_expr| {

datafusion/core/src/physical_planner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ pub fn create_window_expr(
15411541
}
15421542

15431543
type AggregateExprWithOptionalArgs = (
1544-
Arc<AggregateFunctionExpr>,
1544+
AggregateFunctionExpr,
15451545
// The filter clause, if any
15461546
Option<Arc<dyn PhysicalExpr>>,
15471547
// Ordering requirements, if any

datafusion/core/src/test_util/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl TestAggregate {
427427
}
428428

429429
/// Return appropriate expr depending if COUNT is for col or table (*)
430-
pub fn count_expr(&self, schema: &Schema) -> Arc<AggregateFunctionExpr> {
430+
pub fn count_expr(&self, schema: &Schema) -> AggregateFunctionExpr {
431431
AggregateExprBuilder::new(count_udaf(), vec![self.column()])
432432
.schema(Arc::new(schema.clone()))
433433
.alias(self.column_name())

datafusion/physical-expr/src/aggregate.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl AggregateExprBuilder {
8888
}
8989
}
9090

91-
pub fn build(self) -> Result<Arc<AggregateFunctionExpr>> {
91+
pub fn build(self) -> Result<AggregateFunctionExpr> {
9292
let Self {
9393
fun,
9494
args,
@@ -132,7 +132,7 @@ impl AggregateExprBuilder {
132132
Some(alias) => alias,
133133
};
134134

135-
Ok(Arc::new(AggregateFunctionExpr {
135+
Ok(AggregateFunctionExpr {
136136
fun: Arc::unwrap_or_clone(fun),
137137
args,
138138
data_type,
@@ -145,7 +145,7 @@ impl AggregateExprBuilder {
145145
input_types: input_exprs_types,
146146
is_reversed,
147147
is_nullable,
148-
}))
148+
})
149149
}
150150

151151
pub fn alias(mut self, alias: impl Into<String>) -> Self {
@@ -332,9 +332,9 @@ impl AggregateFunctionExpr {
332332
/// not implement the method, returns an error. Order insensitive and hard
333333
/// requirement aggregators return `Ok(None)`.
334334
pub fn with_beneficial_ordering(
335-
self: Arc<Self>,
335+
self,
336336
beneficial_ordering: bool,
337-
) -> Result<Option<Arc<AggregateFunctionExpr>>> {
337+
) -> Result<Option<AggregateFunctionExpr>> {
338338
let Some(updated_fn) = self
339339
.fun
340340
.clone()
@@ -461,10 +461,10 @@ impl AggregateFunctionExpr {
461461
/// Typically the "reverse" expression is itself (e.g. SUM, COUNT).
462462
/// For aggregates that do not support calculation in reverse,
463463
/// returns None (which is the default value).
464-
pub fn reverse_expr(&self) -> Option<Arc<AggregateFunctionExpr>> {
464+
pub fn reverse_expr(&self) -> Option<AggregateFunctionExpr> {
465465
match self.fun.reverse_udf() {
466466
ReversedUDAF::NotSupported => None,
467-
ReversedUDAF::Identical => Some(Arc::new(self.clone())),
467+
ReversedUDAF::Identical => Some(self.clone()),
468468
ReversedUDAF::Reversed(reverse_udf) => {
469469
let reverse_ordering_req = reverse_order_bys(&self.ordering_req);
470470
let mut name = self.name().to_string();
@@ -511,7 +511,7 @@ impl AggregateFunctionExpr {
511511
&self,
512512
_args: Vec<Arc<dyn PhysicalExpr>>,
513513
_order_by_exprs: Vec<Arc<dyn PhysicalExpr>>,
514-
) -> Option<Arc<AggregateFunctionExpr>> {
514+
) -> Option<AggregateFunctionExpr> {
515515
None
516516
}
517517

datafusion/physical-expr/src/window/aggregate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::{expressions::PhysicalSortExpr, reverse_order_bys, PhysicalExpr};
4141
/// See comments on [`WindowExpr`] for more details.
4242
#[derive(Debug)]
4343
pub struct PlainAggregateWindowExpr {
44-
aggregate: Arc<AggregateFunctionExpr>,
44+
aggregate: AggregateFunctionExpr,
4545
partition_by: Vec<Arc<dyn PhysicalExpr>>,
4646
order_by: Vec<PhysicalSortExpr>,
4747
window_frame: Arc<WindowFrame>,
@@ -50,7 +50,7 @@ pub struct PlainAggregateWindowExpr {
5050
impl PlainAggregateWindowExpr {
5151
/// Create a new aggregate window function expression
5252
pub fn new(
53-
aggregate: Arc<AggregateFunctionExpr>,
53+
aggregate: AggregateFunctionExpr,
5454
partition_by: &[Arc<dyn PhysicalExpr>],
5555
order_by: &[PhysicalSortExpr],
5656
window_frame: Arc<WindowFrame>,
@@ -64,7 +64,7 @@ impl PlainAggregateWindowExpr {
6464
}
6565

6666
/// Get aggregate expr of AggregateWindowExpr
67-
pub fn get_aggregate_expr(&self) -> &Arc<AggregateFunctionExpr> {
67+
pub fn get_aggregate_expr(&self) -> &AggregateFunctionExpr {
6868
&self.aggregate
6969
}
7070
}

datafusion/physical-expr/src/window/sliding_aggregate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::{expressions::PhysicalSortExpr, reverse_order_bys, PhysicalExpr};
4141
/// See comments on [`WindowExpr`] for more details.
4242
#[derive(Debug)]
4343
pub struct SlidingAggregateWindowExpr {
44-
aggregate: Arc<AggregateFunctionExpr>,
44+
aggregate: AggregateFunctionExpr,
4545
partition_by: Vec<Arc<dyn PhysicalExpr>>,
4646
order_by: Vec<PhysicalSortExpr>,
4747
window_frame: Arc<WindowFrame>,
@@ -50,7 +50,7 @@ pub struct SlidingAggregateWindowExpr {
5050
impl SlidingAggregateWindowExpr {
5151
/// Create a new (sliding) aggregate window function expression.
5252
pub fn new(
53-
aggregate: Arc<AggregateFunctionExpr>,
53+
aggregate: AggregateFunctionExpr,
5454
partition_by: &[Arc<dyn PhysicalExpr>],
5555
order_by: &[PhysicalSortExpr],
5656
window_frame: Arc<WindowFrame>,
@@ -64,7 +64,7 @@ impl SlidingAggregateWindowExpr {
6464
}
6565

6666
/// Get the [AggregateFunctionExpr] of this object.
67-
pub fn get_aggregate_expr(&self) -> &Arc<AggregateFunctionExpr> {
67+
pub fn get_aggregate_expr(&self) -> &AggregateFunctionExpr {
6868
&self.aggregate
6969
}
7070
}

0 commit comments

Comments
 (0)