Compute ScalarFunction properties including return_type
and nullable
on creation
#13825
Labels
enhancement
New feature or request
Is your feature request related to a problem or challenge?
Continue on the discussion from #13756 (comment)
We create scalar function with the defined function
udf
and inputsargs
and keep them inExpr
. We then coerce the inputs in optimizer step withTypeCoercionRewriter
and compute thenullability
when we create physical exprcreate_physical_expr
.Both
return_type
andnullability
are computed based on the inputs which are defined byScalarUDFImpl
in logical layer. As long as we haveudf
andinputs: Vec<Expr>
we can decide whether it has a valid types and what implicit coercion should we do, and we can define thereturn_type
andnullablity
based on those information.I think such properties can be decided as early as possible (when the function is created in logical layer).
Once we have
return_type
, I think we can avoid call ofdata_types_with_scalar_udf
again inExprSchemable::get_type
,coerce_arguments_for_signature_with_scalar_udf
andcreate_physical_expr
Describe the solution you'd like
Compute the
return_type
andnullable
as early as possible.ScalarFunction::new_udf
is used to create function, need to double check if there is other way to create scalar function. We need to make sure they all go to the same computation.Ideally we have something like
Describe alternatives you've considered
No response
Additional context
We create physical expr with logical input and schema which doesn't seem correct too.
The text was updated successfully, but these errors were encountered: