Skip to content

Commit

Permalink
test: add test asserting I_S queries are correct
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Jun 4, 2024
1 parent b391a63 commit 69bb0f1
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
85 changes: 85 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/expected/onecase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[
{
"comment": "Add your test case here for debugging and run go test -run=One.",
"query": "select (select count(*) from user_extra) x from user order by x",
"plan": {
"QueryType": "SELECT",
"Original": "select (select count(*) from user_extra) x from user order by x",
"Instructions": {
"OperatorType": "UncorrelatedSubquery",
"Variant": "PulloutValue",
"PulloutVars": [
"__sq1"
],
"Inputs": [
{
"InputName": "SubQuery",
"OperatorType": "Aggregate",
"Variant": "Scalar",
"Aggregates": "sum_count_star(0) AS count(*)",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select count(*) from user_extra where 1 != 1",
"Query": "select count(*) from user_extra",
"Table": "user_extra"
}
]
},
{
"InputName": "Outer",
"OperatorType": "UncorrelatedSubquery",
"Variant": "PulloutValue",
"PulloutVars": [
"__sq1"
],
"Inputs": [
{
"InputName": "SubQuery",
"OperatorType": "Aggregate",
"Variant": "Scalar",
"Aggregates": "sum_count_star(0) AS count(*)",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select count(*) from user_extra where 1 != 1",
"Query": "select count(*) from user_extra",
"Table": "user_extra"
}
]
},
{
"InputName": "Outer",
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select :__sq1 as x, __sq1, weight_string(__sq1) from `user` where 1 != 1",
"OrderBy": "(1|2) ASC",
"Query": "select :__sq1 as x, __sq1, weight_string(__sq1) from `user` order by __sq1 asc",
"ResultColumns": 1,
"Table": "`user`"
}
]
}
]
},
"TablesUsed": [
"user.user",
"user.user_extra"
]
}
}
]
20 changes: 20 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/filter_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,26 @@
]
}
},
{
"comment": "Check that we don't remove information_schema qualifier",
"query": "select 1 from information_schema.tables where exists(select 1 from information_schema.tables where table_name = 'tables')",
"plan": {
"QueryType": "SELECT",
"Original": "select 1 from information_schema.tables where exists(select 1 from information_schema.tables where table_name = 'tables')",
"Instructions": {
"OperatorType": "Route",
"Variant": "DBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select 1 from information_schema.`tables` where 1 != 1",
"Query": "select 1 from information_schema.`tables` where exists (select 1 from information_schema.`tables` where table_name = :table_name /* VARCHAR */ limit 1)",
"SysTableTableName": "[table_name:VARCHAR(\"tables\")]",
"Table": "information_schema.`tables`"
}
}},

{
"comment": "Composite IN: tuple inside tuple",
"query": "select id from user where ((col1, name), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))",
Expand Down

0 comments on commit 69bb0f1

Please sign in to comment.