-
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
Merged
arthurschreiber
merged 4 commits into
vitessio:main
from
arthurschreiber:arthur/fix-join-with-derived-table-from-union
Jan 13, 2026
Merged
Fix cross shard/keyspace joins with derived tables containing a UNION.
#19046
arthurschreiber
merged 4 commits into
vitessio:main
from
arthurschreiber:arthur/fix-join-with-derived-table-from-union
Jan 13, 2026
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
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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19046 +/- ##
==========================================
- Coverage 69.89% 69.88% -0.01%
==========================================
Files 1612 1613 +1
Lines 215826 216021 +195
==========================================
+ Hits 150857 150974 +117
- Misses 64969 65047 +78 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
systay
approved these changes
Jan 12, 2026
mattlord
approved these changes
Jan 12, 2026
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
96078c6 to
ea99224
Compare
arthurschreiber
commented
Jan 13, 2026
3013332 to
576e9cb
Compare
vitess-bot bot
added a commit
that referenced
this pull request
Jan 13, 2026
…N`. (#19046) Signed-off-by: Arthur Schreiber <[email protected]>
5 tasks
arthurschreiber
pushed a commit
that referenced
this pull request
Jan 14, 2026
…taining a `UNION`. (#19046) (#19137) Signed-off-by: Arthur Schreiber <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
arthurschreiber
added a commit
that referenced
this pull request
Jan 15, 2026
…taining a `UNION`. (#19046) (#19136) Signed-off-by: Arthur Schreiber <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Arthur Schreiber <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Backport to: release-22.0
Needs to be backport to release-22.0
Backport to: release-23.0
Needs to be backport to release-23.0
Component: Query Serving
Type: Bug
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.