-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore: remove deprecated variants of UDF's invoke (invoke, invoke_no_args, invoke_batch) #15123
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
Merged
alamb
merged 5 commits into
apache:main
from
Blizzara:avo/remove-deprecated-invoke-variants
Mar 17, 2025
+60
−114
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ef4058
chore: remove deprecated variants of UDF's invoke (invoke, invoke_no_…
Blizzara dfce924
clippy
Blizzara a8565a8
unused import
Blizzara e528789
Merge remote-tracking branch 'apache/main' into avo/remove-deprecated…
alamb a57d932
Merge remote-tracking branch 'apache/main' into avo/remove-deprecated…
alamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,7 @@ | |
use crate::expr::schema_name_from_exprs_comma_separated_without_space; | ||
use crate::simplify::{ExprSimplifyResult, SimplifyInfo}; | ||
use crate::sort_properties::{ExprProperties, SortProperties}; | ||
use crate::{ | ||
ColumnarValue, Documentation, Expr, ScalarFunctionImplementation, Signature, | ||
}; | ||
use crate::{ColumnarValue, Documentation, Expr, Signature}; | ||
use arrow::datatypes::DataType; | ||
use datafusion_common::{not_impl_err, ExprSchema, Result, ScalarValue}; | ||
use datafusion_expr_common::interval_arithmetic::Interval; | ||
|
@@ -198,53 +196,18 @@ impl ScalarUDF { | |
self.inner.simplify(args, info) | ||
} | ||
|
||
#[deprecated(since = "42.1.0", note = "Use `invoke_with_args` instead")] | ||
pub fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> { | ||
#[allow(deprecated)] | ||
self.inner.invoke(args) | ||
} | ||
|
||
Comment on lines
-201
to
-206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
#[allow(deprecated)] | ||
pub fn is_nullable(&self, args: &[Expr], schema: &dyn ExprSchema) -> bool { | ||
self.inner.is_nullable(args, schema) | ||
} | ||
|
||
#[deprecated(since = "46.0.0", note = "Use `invoke_with_args` instead")] | ||
pub fn invoke_batch( | ||
&self, | ||
args: &[ColumnarValue], | ||
number_rows: usize, | ||
) -> Result<ColumnarValue> { | ||
#[allow(deprecated)] | ||
self.inner.invoke_batch(args, number_rows) | ||
} | ||
|
||
/// Invoke the function on `args`, returning the appropriate result. | ||
/// | ||
/// See [`ScalarUDFImpl::invoke_with_args`] for details. | ||
pub fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> { | ||
self.inner.invoke_with_args(args) | ||
} | ||
|
||
/// Invoke the function without `args` but number of rows, returning the appropriate result. | ||
/// | ||
/// Note: This method is deprecated and will be removed in future releases. | ||
/// User defined functions should implement [`Self::invoke_with_args`] instead. | ||
#[deprecated(since = "42.1.0", note = "Use `invoke_with_args` instead")] | ||
pub fn invoke_no_args(&self, number_rows: usize) -> Result<ColumnarValue> { | ||
#[allow(deprecated)] | ||
self.inner.invoke_no_args(number_rows) | ||
} | ||
|
||
/// Returns a `ScalarFunctionImplementation` that can invoke the function | ||
/// during execution | ||
#[deprecated(since = "42.0.0", note = "Use `invoke_with_args` instead")] | ||
pub fn fun(&self) -> ScalarFunctionImplementation { | ||
let captured = Arc::clone(&self.inner); | ||
#[allow(deprecated)] | ||
Arc::new(move |args| captured.invoke(args)) | ||
} | ||
|
||
/// Get the circuits of inner implementation | ||
pub fn short_circuits(&self) -> bool { | ||
self.inner.short_circuits() | ||
|
@@ -568,47 +531,6 @@ pub trait ScalarUDFImpl: Debug + Send + Sync { | |
true | ||
} | ||
|
||
/// Invoke the function on `args`, returning the appropriate result | ||
/// | ||
/// Note: This method is deprecated and will be removed in future releases. | ||
/// User defined functions should implement [`Self::invoke_with_args`] instead. | ||
#[deprecated(since = "42.1.0", note = "Use `invoke_with_args` instead")] | ||
fn invoke(&self, _args: &[ColumnarValue]) -> Result<ColumnarValue> { | ||
not_impl_err!( | ||
"Function {} does not implement invoke but called", | ||
self.name() | ||
) | ||
} | ||
|
||
/// Invoke the function with `args` and the number of rows, | ||
/// returning the appropriate result. | ||
/// | ||
/// Note: See notes on [`Self::invoke_with_args`] | ||
/// | ||
/// Note: This method is deprecated and will be removed in future releases. | ||
/// User defined functions should implement [`Self::invoke_with_args`] instead. | ||
/// | ||
/// See <https://github.com/apache/datafusion/issues/13515> for more details. | ||
#[deprecated(since = "46.0.0", note = "Use `invoke_with_args` instead")] | ||
fn invoke_batch( | ||
&self, | ||
args: &[ColumnarValue], | ||
number_rows: usize, | ||
) -> Result<ColumnarValue> { | ||
match args.is_empty() { | ||
true => | ||
{ | ||
#[allow(deprecated)] | ||
self.invoke_no_args(number_rows) | ||
} | ||
false => | ||
{ | ||
#[allow(deprecated)] | ||
self.invoke(args) | ||
} | ||
} | ||
} | ||
|
||
/// Invoke the function returning the appropriate result. | ||
/// | ||
/// # Performance | ||
|
@@ -619,23 +541,7 @@ pub trait ScalarUDFImpl: Debug + Send + Sync { | |
/// | ||
/// [`ColumnarValue::values_to_arrays`] can be used to convert the arguments | ||
/// to arrays, which will likely be simpler code, but be slower. | ||
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> { | ||
#[allow(deprecated)] | ||
self.invoke_batch(&args.args, args.number_rows) | ||
} | ||
|
||
/// Invoke the function without `args`, instead the number of rows are provided, | ||
/// returning the appropriate result. | ||
/// | ||
/// Note: This method is deprecated and will be removed in future releases. | ||
/// User defined functions should implement [`Self::invoke_with_args`] instead. | ||
#[deprecated(since = "42.1.0", note = "Use `invoke_with_args` instead")] | ||
fn invoke_no_args(&self, _number_rows: usize) -> Result<ColumnarValue> { | ||
not_impl_err!( | ||
"Function {} does not implement invoke_no_args but called", | ||
self.name() | ||
) | ||
} | ||
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue>; | ||
|
||
/// Returns any aliases (alternate names) for this function. | ||
/// | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about using
not_impl_err
instead ofpainc
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied https://github.com/apache/datafusion/pull/15123/files#diff-351499880963d6a383c92e156e75019cd9ce33107724a9635853d7d4cd1898d0R1602 - but happy to change, would you prefer
not_impl_err
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked other traits, it would prefer
unimplemented!()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this is a test