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

Re-support Signature::Any(0), and add tests for zero argument udfs #13871

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Dec 21, 2024

Which issue does this PR close?

Rationale for this change

As described on #13763

In version s 43.0.0 and earlier of DataFusion, a TypeSignature::Any(0) means your udf could be called with zero arguments:

SELECT my_udf();

However in version 44.0.0 you get a very confusing error that says zero arguments are not supported but then gives you a candidate function is the one it just said was not supported:

SELECT my_udf();

Error during planning: example_union does not support zero arguments. 
No function matches the given name and argument types 'my_udf()'. 
You might need to add explicit type casts.

Candidate functions:
example_union()

I believe @jayzhan211 added this error to try and guide people to ensure people used the newly introduced Signature::Nullary (see #13763 (comment))

What changes are included in this PR?

  1. Add tests showing various ways to call udfs with no arguments
  2. Update Signature::supports_zero_args

Are these changes tested?

Are there any user-facing changes?

@@ -343,6 +343,12 @@ impl TypeSignature {
pub fn supports_zero_argument(&self) -> bool {
match &self {
TypeSignature::Exact(vec) => vec.is_empty(),
TypeSignature::Any(0) => true,
TypeSignature::Variadic(vec) => vec.is_empty(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually think we could consider removing this function entirely (perhaps deprecate) as it is only used to generate errors

@alamb alamb marked this pull request as draft December 21, 2024 14:12
@alamb alamb changed the title Re-support Signature::Any(0), and add tests for zero arguments Re-support Signature::Any(0), and add tests for zero argument udfs Dec 21, 2024
@alamb alamb force-pushed the alamb/signature_nullary branch from 6def9f3 to 2f83cd0 Compare December 21, 2024 14:18
@github-actions github-actions bot removed the sql SQL Planner label Dec 21, 2024
@jayzhan211
Copy link
Contributor

I update the fix here alamb#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make migration to Signature::nullary in 44.0.0 easier / less confusing
2 participants