diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index 4b9449420fad..1dc26b9749c6 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -2484,7 +2484,7 @@ mod test { Ok(DataType::Utf8) } - fn invoke(&self, _args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, _args: ScalarFunctionArgs) -> Result { Ok(ColumnarValue::Scalar(ScalarValue::from("a"))) } } diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rs index 1ce9bef29199..60fe8f267895 100644 --- a/datafusion/expr/src/udf.rs +++ b/datafusion/expr/src/udf.rs @@ -20,7 +20,7 @@ use crate::expr::schema_name_from_exprs_comma_seperated_without_space; use crate::simplify::{ExprSimplifyResult, SimplifyInfo}; use crate::sort_properties::{ExprProperties, SortProperties}; -use crate::{ColumnarValue, Documentation, Expr, Signature}; +use crate::{ColumnarValue, Documentation, Expr, ScalarFunctionImplementation, Signature}; use arrow::datatypes::DataType; use datafusion_common::{not_impl_err, ExprSchema, Result}; use datafusion_expr_common::interval_arithmetic::Interval; @@ -535,9 +535,9 @@ pub trait ScalarUDFImpl: Debug + Send + Sync { /// to arrays, which will likely be simpler code, but be slower. /// Note that this invoke method replaces the original invoke function deprecated in /// version = 42.1.0. - fn invoke(&self, args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result { #[allow(deprecated)] - self.invoke_batch(args.args, args.number_rows) + self.invoke_batch(args.args.as_slice(), args.number_rows) } /// Invoke the function without `args`, instead the number of rows are provided, diff --git a/datafusion/functions/benches/make_date.rs b/datafusion/functions/benches/make_date.rs index b05ce8802f64..77934a7a4955 100644 --- a/datafusion/functions/benches/make_date.rs +++ b/datafusion/functions/benches/make_date.rs @@ -88,7 +88,10 @@ fn criterion_benchmark(c: &mut Criterion) { #[allow(deprecated)] // TODO use invoke_batch black_box( make_date() - .invoke_batch(&[year.clone(), months.clone(), days.clone()], batch_len) + .invoke_batch( + &[year.clone(), months.clone(), days.clone()], + batch_len, + ) .expect("make_date should work on valid values"), ) }) @@ -98,7 +101,7 @@ fn criterion_benchmark(c: &mut Criterion) { let mut rng = rand::thread_rng(); let year = ColumnarValue::Scalar(ScalarValue::Int32(Some(2025))); let month = ColumnarValue::Scalar(ScalarValue::Int32(Some(11))); - let day_arr =Arc::new(days(&mut rng) + let day_arr = Arc::new(days(&mut rng)); let batch_len = day_arr.len(); let days = ColumnarValue::Array(day_arr); diff --git a/datafusion/functions/benches/to_char.rs b/datafusion/functions/benches/to_char.rs index d4e742f05f65..f838af207ac2 100644 --- a/datafusion/functions/benches/to_char.rs +++ b/datafusion/functions/benches/to_char.rs @@ -105,7 +105,7 @@ fn criterion_benchmark(c: &mut Criterion) { #[allow(deprecated)] // TODO use invoke_batch black_box( to_char() - .invoke_batch(&[data.clone(), patterns.clone()], ) + .invoke(&[data.clone(), patterns.clone()]) .expect("to_char should work on valid values"), ) }) diff --git a/datafusion/functions/src/datetime/to_local_time.rs b/datafusion/functions/src/datetime/to_local_time.rs index cc89de123082..57bea7158f6c 100644 --- a/datafusion/functions/src/datetime/to_local_time.rs +++ b/datafusion/functions/src/datetime/to_local_time.rs @@ -321,7 +321,7 @@ impl ScalarUDFImpl for ToLocalTimeFunc { } } - fn invoke(&self, args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result { if args.args.len() != 1 { return exec_err!( "to_local_time function requires 1 argument, got {:?}", @@ -559,7 +559,7 @@ mod tests { fn test_to_local_time_helper(input: ScalarValue, expected: ScalarValue) { let res = ToLocalTimeFunc::new() - .invoke(ScalarFunctionArgs { + .invoke_with_args(ScalarFunctionArgs { args: vec![ColumnarValue::Scalar(input)], number_rows: 1, return_type: &expected.data_type(), diff --git a/datafusion/functions/src/string/ascii.rs b/datafusion/functions/src/string/ascii.rs index 9ec8fe098ad6..5655ee4fd84b 100644 --- a/datafusion/functions/src/string/ascii.rs +++ b/datafusion/functions/src/string/ascii.rs @@ -64,7 +64,7 @@ impl ScalarUDFImpl for AsciiFunc { Ok(Int32) } - fn invoke( + fn invoke_with_args( &self, ScalarFunctionArgs { args, .. }: ScalarFunctionArgs, ) -> Result { diff --git a/datafusion/functions/src/unicode/substr.rs b/datafusion/functions/src/unicode/substr.rs index 5291179cb3be..f6cec9466fae 100644 --- a/datafusion/functions/src/unicode/substr.rs +++ b/datafusion/functions/src/unicode/substr.rs @@ -76,7 +76,7 @@ impl ScalarUDFImpl for SubstrFunc { } } - fn invoke(&self, args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result { make_scalar_function(substr, vec![])(args.args.as_slice()) } diff --git a/datafusion/functions/src/unicode/substrindex.rs b/datafusion/functions/src/unicode/substrindex.rs index b753a5a816c0..243ec252661f 100644 --- a/datafusion/functions/src/unicode/substrindex.rs +++ b/datafusion/functions/src/unicode/substrindex.rs @@ -79,7 +79,7 @@ impl ScalarUDFImpl for SubstrIndexFunc { utf8_to_str_type(&arg_types[0], "substr_index") } - fn invoke(&self, args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result { make_scalar_function(substr_index, vec![])(args.args.as_slice()) } diff --git a/datafusion/functions/src/unicode/translate.rs b/datafusion/functions/src/unicode/translate.rs index 00cb8bb4eaaa..ec8626e1fdc7 100644 --- a/datafusion/functions/src/unicode/translate.rs +++ b/datafusion/functions/src/unicode/translate.rs @@ -77,7 +77,7 @@ impl ScalarUDFImpl for TranslateFunc { utf8_to_str_type(&arg_types[0], "translate") } - fn invoke(&self, args: ScalarFunctionArgs) -> Result { + fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result { make_scalar_function(invoke_translate, vec![])(args.args.as_slice()) } diff --git a/datafusion/physical-expr/src/scalar_function.rs b/datafusion/physical-expr/src/scalar_function.rs index d923c9473caa..31499e2b7733 100644 --- a/datafusion/physical-expr/src/scalar_function.rs +++ b/datafusion/physical-expr/src/scalar_function.rs @@ -146,7 +146,7 @@ impl PhysicalExpr for ScalarFunctionExpr { .all(|arg| matches!(arg, ColumnarValue::Scalar(_))); // evaluate the function - let output = self.fun.invoke(ScalarFunctionArgs { + let output = self.fun.invoke_with_args(ScalarFunctionArgs { args: inputs, number_rows: batch.num_rows(), return_type: &self.return_type,