-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix cross shard/keyspace joins with derived tables containing a UNION.
#19046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arthurschreiber
wants to merge
3
commits into
vitessio:main
Choose a base branch
from
arthurschreiber:arthur/fix-join-with-derived-table-from-union
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix cross shard/keyspace joins with derived tables containing a UNION.
#19046
arthurschreiber
wants to merge
3
commits into
vitessio:main
from
arthurschreiber:arthur/fix-join-with-derived-table-from-union
+79
−0
Conversation
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
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Contributor
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19046 +/- ##
==========================================
+ Coverage 69.88% 69.89% +0.01%
==========================================
Files 1610 1610
Lines 215431 215523 +92
==========================================
+ Hits 150551 150647 +96
+ Misses 64880 64876 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…/fix-join-with-derived-table-from-union Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
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
This fixes an issue in the planner where a cross shard/keyspace join with a derived table wrapping a non-mergeable
UNIONwould fail withVT13001: [BUG] could not find the column '...' on the UNION.I'm not sure if this should be backported. Probably it should.
If I understand the flow of this code correctly, when
sqlparser.CopyOnRewriteis called with aJoinPredicate,JoinPredicate.Cloneis called which replaces theJoinPredicatein theJoinPredicatestrackerwith the modified instance (that contains the rewrittenexpr). Later in the flow that rewritten join predicate is used but at that point the column references are incorrect.To "workaround" this, we're now unwrapping
JoinPredicates into their underlying expressions, so the information in the tracker does not get modified when the rewrite happens throughsqlparser.CopyOnRewrite.Related Issue(s)
Fixes: #19113
Checklist
Deployment Notes
AI Disclosure
Claude code was used to find the cause of the error and to come up with a fix. The fix looks correct to me and solves the particular issue.