[release-23.0] vtgate: fix None routing handling when merging unions (#20629) - #20940
[release-23.0] vtgate: fix None routing handling when merging unions (#20629)#20940vitess-bot[bot] wants to merge 1 commit into
Conversation
|
Hello @GrahamCampbell, there are conflicts in this backport. Please address them in order to merge this Pull Request. You can execute the snippet below to reset your branch and resolve the conflict manually. Make sure you replace |
There was a problem hiding this comment.
Pull request overview
Backports corrected NoneRouting handling when merging vtgate unions, preventing dropped rows and invalid cross-keyspace plans.
Changes:
- Prioritizes
NoneRoutingpairings and tracks inferred keyspaces. - Adds table/keyspace validation for safe union merges.
- Adds planner and end-to-end regression coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
union_cases.json |
Adds union planning fixtures. |
dml_cases.json |
Adds targeted DML planning fixtures. |
union_merging.go |
Implements safe None-route merging. |
route.go |
Preserves inferred None routing state. |
route_planning.go |
Adds keyspace accounting helpers. |
route_planning_test.go |
Tests routing and keyspace accounting. |
misc_routing.go |
Adds inferred-keyspace metadata. |
union_test.go |
Adds execution regressions. |
Suppressed comments (2)
go/vt/vtgate/planbuilder/operators/route_planning_test.go:310
- This second
vindexes.Sourceliteral also tries to initialize the promotedNamefield directly, which is not permitted for keyed literals on the release-23 type and causes a compile error. Initialize its embeddedTableName.
Source: &vindexes.Source{
Name: sqlparser.NewIdentifierCS("src"),
},
go/test/endtoend/vtgate/queries/union/union_test.go:94
- These assertions cover behavior introduced by this release-23 backport, but the query suite also runs against older vtgate binaries and gates version-specific cases elsewhere in this file. Put these two assertions behind
BinaryIsAtLeastAtVersion(23, "vtgate")so compatibility runs do not fail on binaries that predate the fix.
mcmp.AssertMatches("select 1 from dual union select id1 from t1 where id1 in (null)", "[[INT64(1)]]")
mcmp.AssertMatches("select id1 from t1 where id1 in (null) union select 1 from dual", "[[INT64(1)]]")
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return join, Rewrote("logical join to applyJoin ") | ||
| } | ||
|
|
||
| <<<<<<< HEAD |
| Source: &vindexes.Source{ | ||
| Qualifier: sqlparser.NewIdentifierCS(sourceKs), | ||
| Name: sqlparser.NewIdentifierCS("src"), | ||
| }, |
| stmt, err := sqlparser.NewTestParser().Parse( | ||
| fmt.Sprintf("select /*vt+ %s */ 1", sqlparser.DirectiveAllowCrossKeyspaceReads), | ||
| ) |
| mcmp.AssertMatchesNoOrder("select id1, id2 from t1 union select 827, 452 union select id3,id4 from t2", | ||
| "[[INT64(4) INT64(4)] [INT64(1) INT64(1)] [INT64(2) INT64(2)] [INT64(3) INT64(3)] [INT64(827) INT64(452)] [INT64(2) INT64(3)] [INT64(3) INT64(4)] [INT64(5) INT64(5)]]") | ||
| mcmp.AssertMatches("select 1 from dual where 1 IN (select 1 as col union select 2)", "[[INT64(1)]]") | ||
| <<<<<<< HEAD |
| if op, exprs, merged := tryMergeNoneUnion(ctx, lhsRoute, rhsRoute, lhsExprs, rhsExprs, distinct, routingA, routingB, a, b); merged { | ||
| return op, exprs | ||
| } | ||
| checkCrossKeyspaceOp(ctx, lhs, rhs, "UNION") |
Description
This is a backport of #20629