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 noreply@anthropic.com

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 <noreply@anthropic.com>
@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

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Nice fix!

@michae2 reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball).

@DrewKimball
Copy link
Collaborator Author

TFTR!

bors r=michae2

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160580: opt: fix PruneUnionAllCols panic with outer scope columns r=michae2 a=DrewKimball

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 <noreply@anthropic.com>

Co-authored-by: Drew Kimball <drewk@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jan 10, 2026

Build failed:

@yuzefovich
Copy link
Member

courtesy merge

bors retry

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160580: opt: fix PruneUnionAllCols panic with outer scope columns r=michae2 a=DrewKimball

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 <noreply@anthropic.com>

160632: sql/bulkmerge: reuse SST iterator across bulk merge tasks r=spilchen a=spilchen

This change reduces overhead in the bulk merge processor by initializing a single iterator over all input SSTs at startup, rather than creating a new one per task. The iterator is reused across tasks, seeking only when needed.

Informs #159414
Epic: CRDB-48845
Release note: none

Co-authored by: `@jeffswenson`

Co-authored-by: Drew Kimball <drewk@cockroachlabs.com>
Co-authored-by: Matt Spilchen <matt.spilchen@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jan 10, 2026

Build failed (retrying...):

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160580: opt: fix PruneUnionAllCols panic with outer scope columns r=michae2 a=DrewKimball

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 <noreply@anthropic.com>

Co-authored-by: Drew Kimball <drewk@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jan 10, 2026

Build failed:

@yuzefovich
Copy link
Member

courtesy merge 2

bors retry

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160580: opt: fix PruneUnionAllCols panic with outer scope columns r=michae2 a=DrewKimball

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 <noreply@anthropic.com>

Co-authored-by: Drew Kimball <drewk@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jan 10, 2026

Build failed:

  • local_roachtest_fips

@yuzefovich
Copy link
Member

courtesy merge 3

bors retry

craig bot pushed a commit that referenced this pull request Jan 11, 2026
160580: opt: fix PruneUnionAllCols panic with outer scope columns r=michae2 a=DrewKimball

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 <noreply@anthropic.com>

Co-authored-by: Drew Kimball <drewk@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jan 11, 2026

Build failed:

@yuzefovich
Copy link
Member

courtesy merge 4

bors retry

@craig
Copy link
Contributor

craig bot commented Jan 11, 2026

@craig craig bot merged commit 94a1e22 into cockroachdb:master Jan 11, 2026
34 of 35 checks passed
@DrewKimball DrewKimball deleted the prune-cols-fix branch January 12, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: input set contains unknown columns in DO block

4 participants