Align scalar UDF literal args with coerced return fields#23232
Open
Kevin-Li-2025 wants to merge 1 commit into
Open
Align scalar UDF literal args with coerced return fields#23232Kevin-Li-2025 wants to merge 1 commit into
Kevin-Li-2025 wants to merge 1 commit into
Conversation
Signed-off-by: Kevin-Li-2025 <2242139@qq.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
ReturnFieldArgs.scalar_argumentstype doesn't match witharg_fields#19982.Rationale for this change
ReturnFieldArgsexposes both coercedarg_fieldsand optional scalar literal arguments to scalar UDFs. For coerced literal calls such astest_udf(1)where the UDF signature coerces the argument toInt16, the field metadata isInt16but the scalar argument was not aligned with that field. On currentmain, the coerced expression can also appear asCast(Literal), causingscalar_argumentsto beNoneeven though the argument is still a literal.What changes are included in this PR?
ReturnFieldArgs.scalar_argumentsfrom literals after aligning them to the verified/coerced argument fields.Cast/TryCastso coerced constants are still reported as scalar arguments.arg_fields[0].data_type()matches the scalar argument data type for a coercible scalar UDF.Are these changes tested?
cargo fmt --all --checkCARGO_HOME=/Users/yinxiaogou/Documents/github/.cargo-home CARGO_TARGET_DIR=/Users/yinxiaogou/Documents/github/datafusion-target cargo test -p datafusion --test user_defined_integration user_defined::user_defined_scalar_functions::test_return_field_args_scalar_argument_types_match_arg_fields -- --exactI also ran
cargo test -p datafusion --test user_defined_integration user_defined::user_defined_scalar_functions; the new test and 22 other tests passed, while 3 existing tests failed locally becauseARROW_TEST_DATA/PARQUET_TEST_DATAsubmodule data was unavailable in this checkout.