cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

opt: type check VALUES rows after building them

Open DrewKimball opened this issue 6 months ago • 1 comments

The type of a RECORD-returning UDF is not fully resolved until after it is fully built within the optbuilder. Therefore, a VALUES expression with a UDF can only determine its column types after building its rows. We accounted for this in #103078, but that fix was incomplete - building the row resolves the type of the UDF, but does not update the type annotation for any expressions that wrap it (for example, a COALESCE).

This commit fully fixes the type resolution bug by type checking the row once again after it is built. This ensures that the UDF's resolved type is correctly propagated to parent expressions.

Fixes #117101

Release note (bug fix): Fixed a bug that would cause an internal error when the result of a RECORD-returning UDF was wrapped by another expression (such as COALESCE) within a VALUES clause.

DrewKimball avatar Aug 27 '24 04:08 DrewKimball