cockroach
cockroach copied to clipboard
opt: type check VALUES rows after building them
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 Can we merge this?
I updated the re-typing logic to use the previously resolved type rather than the desired type. This is necessary because type annotations in the AST could have been removed by the time we re-type.
TFTRs!
bors r+
Build succeeded:
Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.
Issue #117101: branch-release-23.2, branch-release-24.1, branch-release-24.2, branch-release-24.3.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
Encountered an error creating backports. Some common things that can go wrong:
- The backport branch might have already existed.
- There was a merge conflict.
- The backport branch contained merge commits.
You might need to create your backport manually using the backport tool.
error creating merge commit from aa866dfcab593aac5f97d9359e495059e300c96c to blathers/backport-release-23.2-129706: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []
you may need to manually resolve merge conflicts with the backport tool.
Backport to branch 23.2.x failed. See errors above.
error creating merge commit from aa866dfcab593aac5f97d9359e495059e300c96c to blathers/backport-release-24.1-129706: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []
you may need to manually resolve merge conflicts with the backport tool.
Backport to branch 24.1.x failed. See errors above.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.