Kevin-Li-2025 opened a new pull request, #23232: URL: https://github.com/apache/datafusion/pull/23232
## Which issue does this PR close? - Closes #19982. ## Rationale for this change `ReturnFieldArgs` exposes both coerced `arg_fields` and optional scalar literal arguments to scalar UDFs. For coerced literal calls such as `test_udf(1)` where the UDF signature coerces the argument to `Int16`, the field metadata is `Int16` but the scalar argument was not aligned with that field. On current `main`, the coerced expression can also appear as `Cast(Literal)`, causing `scalar_arguments` to be `None` even though the argument is still a literal. ## What changes are included in this PR? - Build scalar UDF `ReturnFieldArgs.scalar_arguments` from literals after aligning them to the verified/coerced argument fields. - Recognize literals wrapped in `Cast` / `TryCast` so coerced constants are still reported as scalar arguments. - Add a regression test that asserts `arg_fields[0].data_type()` matches the scalar argument data type for a coercible scalar UDF. ## Are these changes tested? - `cargo fmt --all --check` - `CARGO_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 -- --exact` I 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 because `ARROW_TEST_DATA` / `PARQUET_TEST_DATA` submodule data was unavailable in this checkout. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
