Skip to content

Conversation

@DrewKimball
Copy link
Collaborator

Before this change, the PruneUnionAllCols normalization rule would panic in crdb-test builds when the projection above a UnionAll referenced columns from an outer scope (e.g., due to an apply-join or routine). This occurred because the rule computed the needed column set by combining ProjectionOuterCols and passthrough columns, which could include outer scope columns not present in the UnionAll's output. These outer columns were then passed to NeededColMapLeft/Right, which call TranslateColSetStrict and panic when given unknown columns.

This change fixes the issue by intersecting the needed column set with the UnionAll's output columns before passing it to NeededColMapLeft/ Right. This ensures only columns actually present in the UnionAll are translated, preventing the panic.

Fixes #159793

Release note: None

Co-Authored-By: Claude [email protected]

Before this change, the PruneUnionAllCols normalization rule would panic
in crdb-test builds when the projection above a UnionAll referenced
columns from an outer scope (e.g., due to an apply-join or routine).
This occurred because the rule computed the needed column set by
combining ProjectionOuterCols and passthrough columns, which could
include outer scope columns not present in the UnionAll's output. These
outer columns were then passed to NeededColMapLeft/Right, which call
TranslateColSetStrict and panic when given unknown columns.

This change fixes the issue by intersecting the needed column set with
the UnionAll's output columns before passing it to NeededColMapLeft/
Right. This ensures only columns actually present in the UnionAll are
translated, preventing the panic.

Fixes cockroachdb#159793

Release note: None

Co-Authored-By: Claude <[email protected]>
@DrewKimball DrewKimball requested a review from a team as a code owner January 7, 2026 00:27
@DrewKimball DrewKimball requested review from michae2 and removed request for a team January 7, 2026 00:27
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: input set contains unknown columns in DO block

2 participants