Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-isaacs committed Nov 21, 2024
1 parent 47ee14f commit a1b266e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@ mod test {
Ok(DataType::Utf8)
}

fn invoke(&self, _args: ScalarFunctionArgs) -> Result<ColumnarValue> {
fn invoke_with_args(&self, _args: ScalarFunctionArgs) -> Result<ColumnarValue> {
Ok(ColumnarValue::Scalar(ScalarValue::from("a")))
}
}
Expand Down
6 changes: 3 additions & 3 deletions datafusion/expr/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ColumnarValue> {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
#[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,
Expand Down
7 changes: 5 additions & 2 deletions datafusion/functions/benches/make_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
})
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/benches/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/datetime/to_local_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl ScalarUDFImpl for ToLocalTimeFunc {
}
}

fn invoke(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
if args.args.len() != 1 {
return exec_err!(
"to_local_time function requires 1 argument, got {:?}",
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/string/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ScalarUDFImpl for AsciiFunc {
Ok(Int32)
}

fn invoke(
fn invoke_with_args(
&self,
ScalarFunctionArgs { args, .. }: ScalarFunctionArgs,
) -> Result<ColumnarValue> {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/unicode/substr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ScalarUDFImpl for SubstrFunc {
}
}

fn invoke(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(substr, vec![])(args.args.as_slice())
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/unicode/substrindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ScalarUDFImpl for SubstrIndexFunc {
utf8_to_str_type(&arg_types[0], "substr_index")
}

fn invoke(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(substr_index, vec![])(args.args.as_slice())
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/unicode/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ScalarUDFImpl for TranslateFunc {
utf8_to_str_type(&arg_types[0], "translate")
}

fn invoke(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(invoke_translate, vec![])(args.args.as_slice())
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/scalar_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a1b266e

Please sign in to comment.