Skip to content

Commit 6d413a4

Browse files
authored
Remove AggregateFunctionDefinition::Name (#10441)
1 parent 76f9e2e commit 6d413a4

File tree

8 files changed

+3
-38
lines changed

8 files changed

+3
-38
lines changed

datafusion/core/src/physical_planner.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ fn create_physical_name(e: &Expr, is_first_expr: bool) -> Result<String> {
276276
.collect::<Result<Vec<_>>>()?;
277277
Ok(format!("{}({})", fun.name(), names.join(",")))
278278
}
279-
AggregateFunctionDefinition::Name(_) => {
280-
internal_err!("Aggregate function `Expr` with name should be resolved.")
281-
}
282279
},
283280
Expr::GroupingSet(grouping_set) => match grouping_set {
284281
GroupingSet::Rollup(exprs) => Ok(format!(
@@ -1947,11 +1944,6 @@ pub fn create_aggregate_expr_with_name_and_maybe_filter(
19471944
)?;
19481945
(agg_expr, filter, physical_sort_exprs)
19491946
}
1950-
AggregateFunctionDefinition::Name(_) => {
1951-
return internal_err!(
1952-
"Aggregate function name should have been resolved"
1953-
)
1954-
}
19551947
};
19561948
Ok((agg_expr, filter, order_by))
19571949
}

datafusion/expr/src/expr.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,6 @@ pub enum AggregateFunctionDefinition {
515515
BuiltIn(aggregate_function::AggregateFunction),
516516
/// Resolved to a user defined aggregate function
517517
UDF(Arc<crate::AggregateUDF>),
518-
/// A aggregation function constructed with name. This variant can not be executed directly
519-
/// and instead must be resolved to one of the other variants prior to physical planning.
520-
Name(Arc<str>),
521518
}
522519

523520
impl AggregateFunctionDefinition {
@@ -526,7 +523,6 @@ impl AggregateFunctionDefinition {
526523
match self {
527524
AggregateFunctionDefinition::BuiltIn(fun) => fun.name(),
528525
AggregateFunctionDefinition::UDF(udf) => udf.name(),
529-
AggregateFunctionDefinition::Name(func_name) => func_name.as_ref(),
530526
}
531527
}
532528
}
@@ -1857,8 +1853,7 @@ pub(crate) fn create_name(e: &Expr) -> Result<String> {
18571853
null_treatment,
18581854
}) => {
18591855
let name = match func_def {
1860-
AggregateFunctionDefinition::BuiltIn(..)
1861-
| AggregateFunctionDefinition::Name(..) => {
1856+
AggregateFunctionDefinition::BuiltIn(..) => {
18621857
create_function_name(func_def.name(), *distinct, args)?
18631858
}
18641859
AggregateFunctionDefinition::UDF(..) => {
@@ -1878,8 +1873,7 @@ pub(crate) fn create_name(e: &Expr) -> Result<String> {
18781873
info += &format!(" {}", nt);
18791874
}
18801875
match func_def {
1881-
AggregateFunctionDefinition::BuiltIn(..)
1882-
| AggregateFunctionDefinition::Name(..) => {
1876+
AggregateFunctionDefinition::BuiltIn(..) => {
18831877
Ok(format!("{}{}", name, info))
18841878
}
18851879
AggregateFunctionDefinition::UDF(fun) => {

datafusion/expr/src/expr_schema.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ impl ExprSchemable for Expr {
174174
AggregateFunctionDefinition::UDF(fun) => {
175175
Ok(fun.return_type(&data_types)?)
176176
}
177-
AggregateFunctionDefinition::Name(_) => {
178-
internal_err!("Function `Expr` with name should be resolved.")
179-
}
180177
}
181178
}
182179
Expr::Not(_)

datafusion/expr/src/tree_node.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{Expr, GetFieldAccess};
2727
use datafusion_common::tree_node::{
2828
Transformed, TreeNode, TreeNodeIterator, TreeNodeRecursion,
2929
};
30-
use datafusion_common::{internal_err, map_until_stop_and_collect, Result};
30+
use datafusion_common::{map_until_stop_and_collect, Result};
3131

3232
impl TreeNode for Expr {
3333
fn apply_children<F: FnMut(&Self) -> Result<TreeNodeRecursion>>(
@@ -348,9 +348,6 @@ impl TreeNode for Expr {
348348
null_treatment,
349349
)))
350350
}
351-
AggregateFunctionDefinition::Name(_) => {
352-
internal_err!("Function `Expr` with name should be resolved.")
353-
}
354351
},
355352
)?,
356353
Expr::GroupingSet(grouping_set) => match grouping_set {

datafusion/optimizer/src/analyzer/type_coercion.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ impl<'a> TreeNodeRewriter for TypeCoercionRewriter<'a> {
358358
),
359359
)))
360360
}
361-
AggregateFunctionDefinition::Name(_) => {
362-
internal_err!("Function `Expr` with name should be resolved.")
363-
}
364361
},
365362
Expr::WindowFunction(WindowFunction {
366363
fun,

datafusion/optimizer/src/decorrelate.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,6 @@ fn agg_exprs_evaluation_result_on_empty_batch(
398398
AggregateFunctionDefinition::UDF { .. } => {
399399
Transformed::yes(Expr::Literal(ScalarValue::Null))
400400
}
401-
AggregateFunctionDefinition::Name(_) => {
402-
Transformed::yes(Expr::Literal(ScalarValue::Null))
403-
}
404401
},
405402
_ => Transformed::no(expr),
406403
};

datafusion/proto/src/logical_plan/to_proto.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,6 @@ pub fn serialize_expr(
746746
},
747747
))),
748748
},
749-
AggregateFunctionDefinition::Name(_) => {
750-
return Err(Error::NotImplemented(
751-
"Proto serialization error: Trying to serialize a unresolved function"
752-
.to_string(),
753-
));
754-
}
755749
},
756750

757751
Expr::ScalarVariable(_, _) => {

datafusion/substrait/src/logical_plan/producer.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,6 @@ pub fn to_substrait_agg_measure(
733733
}
734734
})
735735
}
736-
AggregateFunctionDefinition::Name(name) => {
737-
internal_err!("AggregateFunctionDefinition::Name({:?}) should be resolved during `AnalyzerRule`", name)
738-
}
739736
}
740737

741738
}

0 commit comments

Comments
 (0)