Fix index oob panic in unparser with mismatched stacked projections#21094
Open
friendlymatthew wants to merge 1 commit intoapache:mainfrom
Open
Fix index oob panic in unparser with mismatched stacked projections#21094friendlymatthew wants to merge 1 commit intoapache:mainfrom
friendlymatthew wants to merge 1 commit intoapache:mainfrom
Conversation
friendlymatthew
commented
Mar 21, 2026
Contributor
Author
friendlymatthew
left a comment
There was a problem hiding this comment.
self review
Comment on lines
+313
to
+316
| if outer_projections.expr.len() != inner_projection.expr.len() { | ||
| return (plan, vec![]); | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
can confirm that when I remove this, the test below will panic
adriangb
approved these changes
Mar 21, 2026
Contributor
adriangb
left a comment
There was a problem hiding this comment.
👍🏻 this fixes a runtime panic (very bad) and causes no other test regressions
1ccec81 to
1ae3bd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This PR adds a length guard in
subquery_alias_inner_query_and_columnsto prevent a panic when outer and inner projections have different expression countsWithout this fix, optimizer passes like
CommonSubexprEliminatecan produce stacked projections where the inner projections has more exprs than the outer. The function iterates overinner_projection.exprby index and uses the same index to accessouter_projections.expr, causing an index oob panicThis PR bails out early when the lengths don't match. This is consistent with all the other early returns in the function that reject non-matching plan shapes