Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate math functions to implement invoke_with_args #14658

Merged
merged 4 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions datafusion/functions/src/math/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ use datafusion_common::{
use datafusion_expr::interval_arithmetic::Interval;
use datafusion_expr::sort_properties::{ExprProperties, SortProperties};
use datafusion_expr::{
ColumnarValue, Documentation, ScalarUDFImpl, Signature, Volatility,
ColumnarValue, Documentation, ScalarFunctionArgs, ScalarUDFImpl, Signature,
Volatility,
};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -168,12 +169,8 @@ impl ScalarUDFImpl for AbsFunc {
}
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
let args = ColumnarValue::values_to_arrays(args)?;
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let args = ColumnarValue::values_to_arrays(&args.args)?;
let [input] = take_function_args(self.name(), args)?;

let input_data_type = input.data_type();
Expand Down
10 changes: 3 additions & 7 deletions datafusion/functions/src/math/cot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use arrow::datatypes::{DataType, Float32Type, Float64Type};

use crate::utils::make_scalar_function;
use datafusion_common::{exec_err, Result};
use datafusion_expr::{ColumnarValue, Documentation};
use datafusion_expr::{ColumnarValue, Documentation, ScalarFunctionArgs};
use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -87,12 +87,8 @@ impl ScalarUDFImpl for CotFunc {
self.doc()
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
make_scalar_function(cot, vec![])(args)
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(cot, vec![])(&args.args)
}
}

Expand Down
11 changes: 4 additions & 7 deletions datafusion/functions/src/math/factorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use datafusion_common::{
arrow_datafusion_err, exec_err, internal_datafusion_err, DataFusionError, Result,
};
use datafusion_expr::{
ColumnarValue, Documentation, ScalarUDFImpl, Signature, Volatility,
ColumnarValue, Documentation, ScalarFunctionArgs, ScalarUDFImpl, Signature,
Volatility,
};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -76,12 +77,8 @@ impl ScalarUDFImpl for FactorialFunc {
Ok(Int64)
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
make_scalar_function(factorial, vec![])(args)
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(factorial, vec![])(&args.args)
}

fn documentation(&self) -> Option<&Documentation> {
Expand Down
11 changes: 4 additions & 7 deletions datafusion/functions/src/math/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ use datafusion_common::{
arrow_datafusion_err, exec_err, internal_datafusion_err, DataFusionError, Result,
};
use datafusion_expr::{
ColumnarValue, Documentation, ScalarUDFImpl, Signature, Volatility,
ColumnarValue, Documentation, ScalarFunctionArgs, ScalarUDFImpl, Signature,
Volatility,
};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -77,12 +78,8 @@ impl ScalarUDFImpl for GcdFunc {
Ok(Int64)
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
make_scalar_function(gcd, vec![])(args)
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(gcd, vec![])(&args.args)
}

fn documentation(&self) -> Option<&Documentation> {
Expand Down
11 changes: 4 additions & 7 deletions datafusion/functions/src/math/iszero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use arrow::datatypes::{DataType, Float32Type, Float64Type};
use datafusion_common::{exec_err, Result};
use datafusion_expr::TypeSignature::Exact;
use datafusion_expr::{
ColumnarValue, Documentation, ScalarUDFImpl, Signature, Volatility,
ColumnarValue, Documentation, ScalarFunctionArgs, ScalarUDFImpl, Signature,
Volatility,
};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -77,12 +78,8 @@ impl ScalarUDFImpl for IsZeroFunc {
Ok(Boolean)
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
make_scalar_function(iszero, vec![])(args)
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(iszero, vec![])(&args.args)
}

fn documentation(&self) -> Option<&Documentation> {
Expand Down
11 changes: 4 additions & 7 deletions datafusion/functions/src/math/lcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use datafusion_common::{
arrow_datafusion_err, exec_err, internal_datafusion_err, DataFusionError, Result,
};
use datafusion_expr::{
ColumnarValue, Documentation, ScalarUDFImpl, Signature, Volatility,
ColumnarValue, Documentation, ScalarFunctionArgs, ScalarUDFImpl, Signature,
Volatility,
};
use datafusion_macros::user_doc;

Expand Down Expand Up @@ -78,12 +79,8 @@ impl ScalarUDFImpl for LcmFunc {
Ok(Int64)
}

fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
make_scalar_function(lcm, vec![])(args)
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
make_scalar_function(lcm, vec![])(&args.args)
}

fn documentation(&self) -> Option<&Documentation> {
Expand Down
Loading
Loading