Align scalar UDF literal args with coerced return fields#23232
Align scalar UDF literal args with coerced return fields#23232Kevin-Li-2025 wants to merge 2 commits into
Conversation
Signed-off-by: Kevin-Li-2025 <2242139@qq.com>
|
This seems to follow a similar approach to a previous PR that attempted this issue: There was some good discussion on there, perhaps can double check that since we found some difficulties with such an approach |
|
Thanks for pointing me back to #20012. I went through that discussion and tightened this PR so it does not take the broad approach that caused the earlier test churn. The latest commit narrows scalar literal recovery to the implicit-cast shape inserted by type coercion, Local checks run:
New CI is now queued on head |
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.