fix: Fix three bugs in query decorrelation#21208
Open
neilconway wants to merge 2 commits intoapache:mainfrom
Open
fix: Fix three bugs in query decorrelation#21208neilconway wants to merge 2 commits intoapache:mainfrom
neilconway wants to merge 2 commits intoapache:mainfrom
Conversation
Contributor
Author
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.
Which issue does this PR close?
Rationale for this change
This PR fixes three separate bugs in query decorrelation:
INsubqueries, an operator precedence error meant that we would consider two filters to be duplicates even if they involved different operators (e.g.,=and>).CASEused to implement "count bug" handling, we referenced the subquery output column without qualifying it by the subquery alias. This could result in name-collisions with unrelated identifiers in the parent query.CASEused for "count bug" handling, we rewrote the parent query to replace references to the subquery output column with the generatedCASEexpression. This rewrite only matched on unqualified column name only, which meant that unrelated parent query identifiers that happened to share the same column name as subquery aggregate aliases could been rewritten by mistake.The first and third issues could result in incorrect query results; the second would only cause spurious errors, as far as I can see.
What changes are included in this PR?
debug_assert!to document/check thatremove_duplicated_filteris called with a commutative operatorAre these changes tested?
Yes.
Are there any user-facing changes?
No, except in the sense that they fix user-visible bugs.