Apache DataFusion SQL Query Engine
Remove AggregateFunctionDefinition::Name (#10441)
张林伟6d413a4b52fc
diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rsindex 132bc3953c..d4a9a949fc 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<String> {.collect::<Result<Vec<_>>>()?;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.rsindex c531d7af17..84e4cb6435 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 functionUDF(Arc<crate::AggregateUDF>),- /// 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<str>),}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(),}}}@@ -1857,8 +1853,7 @@ pub(crate) fn create_name(e: &Expr) -> Result<String> {null_treatment,}) => {let name = match func_def {- AggregateFunctionDefinition::BuiltIn(..)- | AggregateFunctionDefinition::Name(..) => {+ AggregateFunctionDefinition::BuiltIn(..) => {create_function_name(func_def.name(), *distinct, args)?}AggregateFunctionDefinition::UDF(..) => {@@ -1878,8 +1873,7 @@ pub(crate) fn create_name(e: &Expr) -> Result<String> {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.rsindex ce79f9da64..2c08dbe042 100644--- a/datafusion/expr/src/expr_schema.rs+++ b/datafusion/expr/src/expr_schema.rs@@ -174,9 +174,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.rsindex 710164eca3..1b3b5e8fcb 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<F: FnMut(&Self) -> Result<TreeNodeRecursion>>(@@ -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.rsindex e5c7afa10e..994adf7327 100644--- a/datafusion/optimizer/src/analyzer/type_coercion.rs+++ b/datafusion/optimizer/src/analyzer/type_coercion.rs@@ -358,9 +358,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.rsindex a6abec9efd..3959223e68 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.rsindex 4c29d7551b..ecdbde6faf 100644--- a/datafusion/proto/src/logical_plan/to_proto.rs+++ b/datafusion/proto/src/logical_plan/to_proto.rs@@ -746,12 +746,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.rsindex 39b2b0aa16..db5d341bc2 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)- }}}