Skip to content

Allow type coersion of zero input arrays to nullary #15487

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

Conversation

timsaucer
Copy link
Contributor

Which issue does this PR close?

None

Rationale for this change

During testing for aggregate UDFs via FFI I discovered that if we have a UDF with a nullary type signature, it cannot use the coercion functions with arguments of zero lenght. This PR adjusts for that fact.

Additional testing showed that we need to implement return_type_from_args or some UDFs would fail. This PR implements it.

What changes are included in this PR?

In addition to the two changes above, there are some moving around of the FFI integration tests now that they're getting larger. Basically I split them into a couple of files.

Are these changes tested?

Unit test added.

…coerce empty vector of arguments to nullary due to check. This also exposes return_type_from_args instead of just return_type that was causing some UDFs to fail. Added unit tests and moved around FFI test modules a little.
@github-actions github-actions bot added logical-expr Logical plan and expressions ffi Changes to the ffi crate labels Mar 29, 2025
@timsaucer timsaucer marked this pull request as draft March 29, 2025 13:57
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Mar 29, 2025
@github-actions github-actions bot added the sql SQL Planner label Mar 29, 2025
@timsaucer timsaucer marked this pull request as ready for review March 29, 2025 15:02
@timsaucer
Copy link
Contributor Author

@jayzhan211 Would you mind reviewing, specifically the part in datafusion/expr/src/type_coercion/functions.rs since you were the prior author?

@timsaucer timsaucer merged commit fe3b101 into apache:main Mar 31, 2025
27 checks passed
nirnayroy pushed a commit to nirnayroy/datafusion that referenced this pull request May 2, 2025
* ScalarUDF via FFI would break with nullary type inputs. We could not coerce empty vector of arguments to nullary due to check. This also exposes return_type_from_args instead of just return_type that was causing some UDFs to fail. Added unit tests and moved around FFI test modules a little.

* Add license text

* Correct error in documentation

* Error message changed in test due to updated scalar coercion

* Perform check of user defined types when looking for empty argument types

* Updated error messages during unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ffi Changes to the ffi crate logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants