Skip to main content

push_function_arg_types

Function push_function_arg_types 

Source
fn push_function_arg_types<F>(func: &F, args: &mut [Expr]) -> Result<()>
where F: UDFCoercionExt,
Expand description

Infers static output types for untyped json_get arguments from a function signature.

DataFusion requires every expression to have one Arrow data type during planning. A JSON path may contain heterogeneous values across rows, but it cannot expose those values as different Arrow types in one result column. Preserving their runtime types would require a single Variant-like data type and Variant-aware functions instead. Maybe we can wait for https://github.com/apache/datafusion/issues/16116

This helper uses the function’s coercion rules to select a supported output type, then appends a typed NULL argument to each relevant json_get. The typed argument makes json_get project compatible JSON values to that type and return NULL for incompatible values. Functions that accept json_get’s default Utf8View output keep the two-argument form so later rewrites can still push down an outer cast.