Skip to content

Conversation

@arthurschreiber
Copy link
Member

@arthurschreiber arthurschreiber commented Jan 14, 2026

Description

This is a followup to #19046.

It fixes an issue where UNION queries couldn't push down predicates correctly when a column name in the first SELECT of the union was using upper case characters while the predicate used lower case names. This caused an additional FILTER operation to be added to queries, which in turn could prevent route merging.

This pull request fixes this issue by ensuring that both building the offset map and lookups into the offset map use lowercase column names.

This also fixes an issue introduced via #19046, where we added the join predicate unwrapping. This seemingly fixed the issue that pull request attempted to fix, but the fix broke down with the changes added in this PR - it caused all sorts of issues with information_schema queries.

Instead of unwrapping the JoinPredicate, we create new JoinPredicate objects for every source of the UNION. This allows the existing code to modify/restore the JoinPredicates pushed down into the UNIONs correctly in cases where those modifications need to be reverted (which can happen if LHS and RHS of an ApplyJoin get merged).

Related Issue(s)

Related to #19113

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

AI Disclosure

@github-actions github-actions bot added this to the v24.0.0 milestone Jan 14, 2026
@vitess-bot vitess-bot bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jan 14, 2026
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Jan 14, 2026

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.91%. Comparing base (d38ee62) to head (44e634c).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtgate/planbuilder/operators/union.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19139   +/-   ##
=======================================
  Coverage   69.90%   69.91%           
=======================================
  Files        1613     1613           
  Lines      216076   216071    -5     
=======================================
+ Hits       151055   151060    +5     
+ Misses      65021    65011   -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arthurschreiber arthurschreiber added Type: Bug 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 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsIssue A linked issue is missing for this Pull Request labels Jan 14, 2026
@arthurschreiber arthurschreiber marked this pull request as ready for review January 14, 2026 16:49
needsFilter = true
cursor.StopTreeWalk()
return
panic(vterrors.VT13001(fmt.Sprintf("could not find the column '%s' on the UNION", sqlparser.String(col))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying this is wrong, I don't know so asking. Is panic (crashing the vtgate) the right thing to do vs returning a query error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing, but panic inside the planner package does not crash the vtgate, it's the canonical way to return an error from inside the planner back to the vtgate.

@arthurschreiber arthurschreiber merged commit 4211114 into main Jan 16, 2026
116 of 130 checks passed
@arthurschreiber arthurschreiber deleted the arthur/fix-union-column-case-sensitivity branch January 16, 2026 08:26
vitess-bot bot added a commit that referenced this pull request Jan 16, 2026
arthurschreiber pushed a commit that referenced this pull request Jan 16, 2026
…ensitive. (#19139) (#19162)

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 16, 2026
…ensitive. (#19139) (#19161)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants