You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2023/07/26 19:22:28 UTC
[arrow-datafusion] branch main updated: change the input_type parameter of the create_udaf function from DataType to Vec (#7096)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 581778df4c change the input_type parameter of the create_udaf function from DataType to Vec<DataType> (#7096)
581778df4c is described below
commit 581778df4c69563803d00358991486be3542a95f
Author: zhenxing jiang <ji...@gmail.com>
AuthorDate: Thu Jul 27 03:22:22 2023 +0800
change the input_type parameter of the create_udaf function from DataType to Vec<DataType> (#7096)
---
datafusion-examples/examples/simple_udaf.rs | 2 +-
datafusion/core/src/execution/context.rs | 2 +-
datafusion/core/src/physical_plan/windows/mod.rs | 2 +-
datafusion/core/tests/sql/udf.rs | 4 ++--
datafusion/expr/src/expr_fn.rs | 4 ++--
datafusion/optimizer/src/analyzer/type_coercion.rs | 2 +-
datafusion/proto/src/bytes/mod.rs | 2 +-
datafusion/proto/src/logical_plan/mod.rs | 4 ++--
8 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/datafusion-examples/examples/simple_udaf.rs b/datafusion-examples/examples/simple_udaf.rs
index 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.rs
index c6f082f1eb..811c2ec765 100644
--- a/datafusion/core/src/execution/context.rs
+++ b/datafusion/core/src/execution/context.rs
@@ -2248,7 +2248,7 @@ mod tests {
// Note capitalization
let 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.rs
index 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.rs
index 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 accumulator
let 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.rs
index 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.rs
index 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.rs
index 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.rs
index 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,