Apache DataFusion SQL Query Engine
change the input_type parameter of the create_udaf function from DataType to Vec<DataType> (#7096)
zhenxing jiang581778df4c69
diff --git a/datafusion-examples/examples/simple_udaf.rs b/datafusion-examples/examples/simple_udaf.rsindex e3b290cc54..7aec9698d9 100644--- a/datafusion-examples/examples/simple_udaf.rs+++ b/datafusion-examples/examples/simple_udaf.rs@@ -145,7 +145,7 @@ async fn main() -> Result<()> {// the name; used to represent it in plan descriptions and in the registry, to use in SQL."geo_mean",// the input type; DataFusion guarantees that the first entry of `values` in `update` has this type.- DataType::Float64,+ vec![DataType::Float64],// the return type; DataFusion expects this to match the type returned by `evaluate`.Arc::new(DataType::Float64),Volatility::Immutable,diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rsindex c6f082f1eb..811c2ec765 100644--- a/datafusion/core/src/execution/context.rs+++ b/datafusion/core/src/execution/context.rs@@ -2248,7 +2248,7 @@ mod tests {// Note capitalizationlet my_avg = create_udaf("MY_AVG",- DataType::Float64,+ vec![DataType::Float64],Arc::new(DataType::Float64),Volatility::Immutable,Arc::new(|_| {diff --git a/datafusion/core/src/physical_plan/windows/mod.rs b/datafusion/core/src/physical_plan/windows/mod.rsindex 9b44ac615c..7d9d70f477 100644--- a/datafusion/core/src/physical_plan/windows/mod.rs+++ b/datafusion/core/src/physical_plan/windows/mod.rs@@ -539,7 +539,7 @@ mod tests {let my_count = create_udaf("my_count",- DataType::Int64,+ vec![DataType::Int64],Arc::new(DataType::Int64),Volatility::Immutable,Arc::new(|_| Ok(Box::new(MyCount(0)))),diff --git a/datafusion/core/tests/sql/udf.rs b/datafusion/core/tests/sql/udf.rsindex 0ecd5d0fde..2907d46806 100644--- a/datafusion/core/tests/sql/udf.rs+++ b/datafusion/core/tests/sql/udf.rs@@ -234,7 +234,7 @@ async fn simple_udaf() -> Result<()> {// define a udaf, using a DataFusion's accumulatorlet my_avg = create_udaf("my_avg",- DataType::Float64,+ vec![DataType::Float64],Arc::new(DataType::Float64),Volatility::Immutable,Arc::new(|_| {@@ -291,7 +291,7 @@ async fn udaf_as_window_func() -> Result<()> {let my_acc = create_udaf("my_acc",- DataType::Int32,+ vec![DataType::Int32],Arc::new(DataType::Int32),Volatility::Immutable,Arc::new(|_| Ok(Box::new(MyAccumulator))),diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rsindex 418aa8d8f8..a48b5e0bee 100644--- a/datafusion/expr/src/expr_fn.rs+++ b/datafusion/expr/src/expr_fn.rs@@ -801,7 +801,7 @@ pub fn create_udf(/// The signature and state type must match the `Accumulator's implementation`.pub fn create_udaf(name: &str,- input_type: DataType,+ input_type: Vec<DataType>,return_type: Arc<DataType>,volatility: Volatility,accumulator: AccumulatorFactoryFunction,@@ -811,7 +811,7 @@ pub fn create_udaf(let state_type: StateTypeFunction = Arc::new(move |_| Ok(state_type.clone()));AggregateUDF::new(name,- &Signature::exact(vec![input_type], volatility),+ &Signature::exact(input_type, volatility),&return_type,&accumulator,&state_type,diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rsindex 8279f68e3c..2bd7fd67d8 100644--- a/datafusion/optimizer/src/analyzer/type_coercion.rs+++ b/datafusion/optimizer/src/analyzer/type_coercion.rs@@ -890,7 +890,7 @@ mod test {let empty = empty();let my_avg = create_udaf("MY_AVG",- DataType::Float64,+ vec![DataType::Float64],Arc::new(DataType::Float64),Volatility::Immutable,Arc::new(|_| {diff --git a/datafusion/proto/src/bytes/mod.rs b/datafusion/proto/src/bytes/mod.rsindex 01a192324b..566dffb535 100644--- a/datafusion/proto/src/bytes/mod.rs+++ b/datafusion/proto/src/bytes/mod.rs@@ -124,7 +124,7 @@ impl Serializeable for Expr {fn udaf(&self, name: &str) -> Result<Arc<AggregateUDF>> {Ok(Arc::new(create_udaf(name,- arrow::datatypes::DataType::Null,+ vec![arrow::datatypes::DataType::Null],Arc::new(arrow::datatypes::DataType::Null),Volatility::Immutable,Arc::new(|_| unimplemented!()),diff --git a/datafusion/proto/src/logical_plan/mod.rs b/datafusion/proto/src/logical_plan/mod.rsindex 27f9389678..9d7017eec6 100644--- a/datafusion/proto/src/logical_plan/mod.rs+++ b/datafusion/proto/src/logical_plan/mod.rs@@ -2688,7 +2688,7 @@ mod roundtrip_tests {// the name; used to represent it in plan descriptions and in the registry, to use in SQL."dummy_agg",// the input type; DataFusion guarantees that the first entry of `values` in `update` has this type.- DataType::Float64,+ vec![DataType::Float64],// the return type; DataFusion expects this to match the type returned by `evaluate`.Arc::new(DataType::Float64),Volatility::Immutable,@@ -2874,7 +2874,7 @@ mod roundtrip_tests {// the name; used to represent it in plan descriptions and in the registry, to use in SQL."dummy_agg",// the input type; DataFusion guarantees that the first entry of `values` in `update` has this type.- DataType::Float64,+ vec![DataType::Float64],// the return type; DataFusion expects this to match the type returned by `evaluate`.Arc::new(DataType::Float64),Volatility::Immutable,