Skip to content

Commit

Permalink
[release-19.0] fix: remove keyspace when merging subqueries (#16019) (#…
Browse files Browse the repository at this point in the history
…16027)

Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
  • Loading branch information
vitess-bot[bot] authored May 30, 2024
1 parent 6bfdccf commit 4f5b9d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions go/vt/vtgate/planbuilder/operators/subquery_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ func tryMergeSubqueryWithOuter(ctx *plancontext.PlanningContext, subQuery *SubQu
return outer, NoRewrite
}
exprs := subQuery.GetMergePredicates()
sqlparser.RemoveKeyspace(subQuery.Original)
merger := &subqueryRouteMerger{
outer: outer,
original: subQuery.Original,
Expand Down
23 changes: 23 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/filter_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,29 @@
]
}
},
{
"comment": "Merging subqueries should remove keyspace from query",
"query": "select u.id from user.user as u where not exists (select 1 from user.user_extra as ue where u.id = ue.user_id)",
"plan": {
"QueryType": "SELECT",
"Original": "select u.id from user.user as u where not exists (select 1 from user.user_extra as ue where u.id = ue.user_id)",
"Instructions": {
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select u.id from `user` as u where 1 != 1",
"Query": "select u.id from `user` as u where not exists (select 1 from user_extra as ue where u.id = ue.user_id)",
"Table": "`user`"
},
"TablesUsed": [
"user.user",
"user.user_extra"
]
}
},
{
"comment": "Single table equality route with unsigned value",
"query": "select id from user where name = 18446744073709551615",
Expand Down

0 comments on commit 4f5b9d9

Please sign in to comment.