Fix query optimization for semijoins#4287
Open
joshua-spacetime wants to merge 1 commit intomasterfrom
Open
Conversation
5a48704 to
5be71e4
Compare
5be71e4 to
b8bdaba
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.
Description of Changes
Fixes a planner bug where certain join queries could fail with:
The reason was that in the process of rewriting the query with semijoins, the fallback branch of the optimization rule didn't track the dependencies of the join correctly. In particular it didn't mark the LHS table in the join condition as a dependency when recursing into the LHS of the join tree. This led to the table being projected out or dropped in the LHS subtree while still being referenced by the root of the subtree.
This only happened for bridge tables (tables used to link or bridge other tables in the join, but whose columns are not referenced in the final output). If the table was referenced in the output, it would be included in the list of dependencies from the start and so this bug would not manifest.
API and ABI breaking changes
None
Expected complexity level and risk
1
Testing
Added a sql execution test