diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs index 132bc3953cd3..d4a9a949fc41 100644 --- a/datafusion/core/src/physical_planner.rs +++ b/datafusion/core/src/physical_planner.rs @@ -276,9 +276,6 @@ fn create_physical_name(e: &Expr, is_first_expr: bool) -> Result { .collect::>>()?; Ok(format!("{}({})", fun.name(), names.join(","))) } - AggregateFunctionDefinition::Name(_) => { - internal_err!("Aggregate function `Expr` with name should be resolved.") - } }, Expr::GroupingSet(grouping_set) => match grouping_set { GroupingSet::Rollup(exprs) => Ok(format!( @@ -1947,11 +1944,6 @@ pub fn create_aggregate_expr_with_name_and_maybe_filter( )?; (agg_expr, filter, physical_sort_exprs) } - AggregateFunctionDefinition::Name(_) => { - return internal_err!( - "Aggregate function name should have been resolved" - ) - } }; Ok((agg_expr, filter, order_by)) } diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index 01ef2571ea82..ed55b7b3c24e 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -515,9 +515,6 @@ pub enum AggregateFunctionDefinition { BuiltIn(aggregate_function::AggregateFunction), /// Resolved to a user defined aggregate function UDF(Arc), - /// A aggregation function constructed with name. This variant can not be executed directly - /// and instead must be resolved to one of the other variants prior to physical planning. - Name(Arc), } impl AggregateFunctionDefinition { @@ -526,7 +523,6 @@ impl AggregateFunctionDefinition { match self { AggregateFunctionDefinition::BuiltIn(fun) => fun.name(), AggregateFunctionDefinition::UDF(udf) => udf.name(), - AggregateFunctionDefinition::Name(func_name) => func_name.as_ref(), } } } @@ -1829,8 +1825,7 @@ pub(crate) fn create_name(e: &Expr) -> Result { null_treatment, }) => { let name = match func_def { - AggregateFunctionDefinition::BuiltIn(..) - | AggregateFunctionDefinition::Name(..) => { + AggregateFunctionDefinition::BuiltIn(..) => { create_function_name(func_def.name(), *distinct, args)? } AggregateFunctionDefinition::UDF(..) => { @@ -1850,8 +1845,7 @@ pub(crate) fn create_name(e: &Expr) -> Result { info += &format!(" {}", nt); } match func_def { - AggregateFunctionDefinition::BuiltIn(..) - | AggregateFunctionDefinition::Name(..) => { + AggregateFunctionDefinition::BuiltIn(..) => { Ok(format!("{}{}", name, info)) } AggregateFunctionDefinition::UDF(fun) => { diff --git a/datafusion/expr/src/expr_schema.rs b/datafusion/expr/src/expr_schema.rs index 4aca52d67c4f..8b07c556fefc 100644 --- a/datafusion/expr/src/expr_schema.rs +++ b/datafusion/expr/src/expr_schema.rs @@ -173,9 +173,6 @@ impl ExprSchemable for Expr { AggregateFunctionDefinition::UDF(fun) => { Ok(fun.return_type(&data_types)?) } - AggregateFunctionDefinition::Name(_) => { - internal_err!("Function `Expr` with name should be resolved.") - } } } Expr::Not(_) diff --git a/datafusion/expr/src/tree_node.rs b/datafusion/expr/src/tree_node.rs index 710164eca3d0..1b3b5e8fcb83 100644 --- a/datafusion/expr/src/tree_node.rs +++ b/datafusion/expr/src/tree_node.rs @@ -27,7 +27,7 @@ use crate::{Expr, GetFieldAccess}; use datafusion_common::tree_node::{ Transformed, TreeNode, TreeNodeIterator, TreeNodeRecursion, }; -use datafusion_common::{internal_err, map_until_stop_and_collect, Result}; +use datafusion_common::{map_until_stop_and_collect, Result}; impl TreeNode for Expr { fn apply_children Result>( @@ -348,9 +348,6 @@ impl TreeNode for Expr { null_treatment, ))) } - AggregateFunctionDefinition::Name(_) => { - internal_err!("Function `Expr` with name should be resolved.") - } }, )?, Expr::GroupingSet(grouping_set) => match grouping_set { diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs index 61b1d1d77b20..8130e09e2989 100644 --- a/datafusion/optimizer/src/analyzer/type_coercion.rs +++ b/datafusion/optimizer/src/analyzer/type_coercion.rs @@ -353,9 +353,6 @@ impl<'a> TreeNodeRewriter for TypeCoercionRewriter<'a> { ), ))) } - AggregateFunctionDefinition::Name(_) => { - internal_err!("Function `Expr` with name should be resolved.") - } }, Expr::WindowFunction(WindowFunction { fun, diff --git a/datafusion/optimizer/src/decorrelate.rs b/datafusion/optimizer/src/decorrelate.rs index a6abec9efd8c..3959223e68c1 100644 --- a/datafusion/optimizer/src/decorrelate.rs +++ b/datafusion/optimizer/src/decorrelate.rs @@ -398,9 +398,6 @@ fn agg_exprs_evaluation_result_on_empty_batch( AggregateFunctionDefinition::UDF { .. } => { Transformed::yes(Expr::Literal(ScalarValue::Null)) } - AggregateFunctionDefinition::Name(_) => { - Transformed::yes(Expr::Literal(ScalarValue::Null)) - } }, _ => Transformed::no(expr), }; diff --git a/datafusion/proto/src/logical_plan/to_proto.rs b/datafusion/proto/src/logical_plan/to_proto.rs index 80acd12e4e60..a18f0eb01bb3 100644 --- a/datafusion/proto/src/logical_plan/to_proto.rs +++ b/datafusion/proto/src/logical_plan/to_proto.rs @@ -750,12 +750,6 @@ pub fn serialize_expr( }, ))), }, - AggregateFunctionDefinition::Name(_) => { - return Err(Error::NotImplemented( - "Proto serialization error: Trying to serialize a unresolved function" - .to_string(), - )); - } }, Expr::ScalarVariable(_, _) => { diff --git a/datafusion/substrait/src/logical_plan/producer.rs b/datafusion/substrait/src/logical_plan/producer.rs index 39b2b0aa1606..db5d341bc225 100644 --- a/datafusion/substrait/src/logical_plan/producer.rs +++ b/datafusion/substrait/src/logical_plan/producer.rs @@ -733,9 +733,6 @@ pub fn to_substrait_agg_measure( } }) } - AggregateFunctionDefinition::Name(name) => { - internal_err!("AggregateFunctionDefinition::Name({:?}) should be resolved during `AnalyzerRule`", name) - } } }