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

chore: remove deprecated variants of UDF's invoke (invoke, invoke_no_args, invoke_batch) #15123

Merged
merged 5 commits into from
Mar 17, 2025

Conversation

Blizzara
Copy link
Contributor

@Blizzara Blizzara commented Mar 10, 2025

Leaving only invoke_with_args

Which issue does this PR close?

Followup form #15049

Rationale for this change

The UDF trait has 4 different ways of implementing invoke, with 3 of them deprecated. This cleans the trait up.

What changes are included in this PR?

  • invoke, invoke_no_args, and invoke_batch are removed
  • invoke_with_args has its default implementation removed, forcing users to implement it
  • ScalarUDFImpl::fun is also removed, since that's been deprecated for a while and uses invoke
  • max UDF is fixed to implement invoke_with_args instead
  • a test dummy UDF is fixed to implement invoke_with_args instead

Are these changes tested?

Existing tests

Are there any user-facing changes?

yes, BREAKING CHANGE: remove deprecated variants of UDF's invoke (invoke, invoke_no_args, invoke_batch)

…args, invoke_batch)

Leaving only invoke_with_args
@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Mar 10, 2025
@github-actions github-actions bot added sql SQL Planner core Core DataFusion crate proto Related to proto crate labels Mar 10, 2025
@@ -89,6 +92,10 @@ impl ScalarUDFImpl for DummyUDF {
fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(DataType::Int32)
}

fn invoke_with_args(&self, _args: ScalarFunctionArgs) -> Result<ColumnarValue> {
panic!("dummy - not implemented")
Copy link
Member

@Weijun-H Weijun-H Mar 10, 2025

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 of painc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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!().

Copy link
Contributor

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

Comment on lines -217 to -206
#[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)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@goldmedal

This comment was marked as resolved.

@alamb
Copy link
Contributor

alamb commented Mar 10, 2025

Should we remove the deprecated UDF API now? According to our API health policy:

Deprecated methods will remain in the codebase for a period of 6 major versions or 6 months, whichever is longer, to provide users ample time to transition away from them.

They were annotated on 2024/11/22. I think we should keep them until at least 2025/05/22 or 48.0.0. I'm not sure if downstream projects have updated their usage.

In general this is true -- however, in this case since several of the example APIs can't actually be used (see this section of the upgrade guide) I think it is worth considering just removing the APIs and forcing downstream crates to update

@Blizzara
Copy link
Contributor Author

Yeah, from my perspective this one isn't so bad - implementing any of the deprecated methods is kinda okay, since the defaults are wired to propagate the call correctly here. Calling them is not fine, but as they're marked as deprecated that should be enough to prevent the calls.

The other removal (return_type_from_exprs) is more important since there the call chain doesn't work.

But then if we do one removal, it might make sense to just do the other one too, to end up with a clean interface.. Up to you guys, I'm happy to have this merged or turn it back into draft and merge later :)

@alamb
Copy link
Contributor

alamb commented Mar 13, 2025

But then if we do one removal, it might make sense to just do the other one too, to end up with a clean interface.. Up to you guys, I'm happy to have this merged or turn it back into draft and merge later :)

I agree

I made a note on the release ticket that we should write a note in the upgrade guide

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Blizzara -- I think we should make this change even though it isn't following the normal deprecation cycle

I think an API that compiles but errors at runtime is even worse than having to fix a compiler error.

@alamb
Copy link
Contributor

alamb commented Mar 16, 2025

I merged this PR up from main and plan to leave it open for a day or two more. Then I'll merge it in.

@alamb
Copy link
Contributor

alamb commented Mar 16, 2025

Leaving only invoke_with_args

done-and-done-spongebob

@alamb alamb merged commit 6be228c into apache:main Mar 17, 2025
27 checks passed
@alamb
Copy link
Contributor

alamb commented Mar 17, 2025

🔨 let's go

@alamb
Copy link
Contributor

alamb commented Mar 17, 2025

Thanks again @Weijun-H @jayzhan211 and @Blizzara

@Blizzara Blizzara deleted the avo/remove-deprecated-invoke-variants branch March 20, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules proto Related to proto crate sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate and eventually remove ScalarUDF::invoke_batch
5 participants