Skip to content

Handle nulls in type coercion of higher-order UDFs, map_extract, spark repeat#23071

Open
gstvg wants to merge 1 commit into
apache:mainfrom
gstvg:null_arg_type_coercion
Open

Handle nulls in type coercion of higher-order UDFs, map_extract, spark repeat#23071
gstvg wants to merge 1 commit into
apache:mainfrom
gstvg:null_arg_type_coercion

Conversation

@gstvg

@gstvg gstvg commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Unresolved lambda variables and unspecified placeholders report a DataType::Null data type, which causes an error when used as argument of a function that doesn't handle nulls during type coercion

What changes are included in this PR?

Handle null in coerce_single_list_arg for higher-order functions, map_extract and in spark repeat. All other functions (scalar, window, agg and higher-order) that uses user defined type coercion have been checked to currently handle null args.

Are these changes tested?

Test passing array_filter with an unresolved lambda variable to Dataframe::with_column (which indirectly calls value_fields_with_higher_order_udf_and_lambdas coercion via Projection::try_new, projection_schema, exprlist_to_fields, Expr::to_field )

Are there any user-facing changes?

No

@github-actions github-actions Bot added core Core DataFusion crate functions Changes to functions implementation spark labels Jun 22, 2026
fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
let [map_type, _] = take_function_args(self.name(), arg_types)?;

if map_type.is_null() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Null is accepted in coercion, but return_type still calls get_map_entry_field on the same Null type. So
map_extract(NULL, 'a') still fails with an internal error.

We should also add a test for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate functions Changes to functions implementation spark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in lambda variable resolution

2 participants