Skip to content
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

Move UNION planning to the operators #13450

Merged
merged 46 commits into from
Aug 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ad06b80
start moving UNION planning over to the operators
systay Jul 6, 2023
7e89fdd
rename the slices2 package to slice
systay Jul 6, 2023
5b6b159
rename Merge to MergeJoin to make place for MergeUnion
systay Jul 6, 2023
5951c26
rewrite the compact rules for UNION
systay Jul 6, 2023
2179342
Make UNION compact more efficient
systay Jul 7, 2023
6ea5eda
another attempt at offset planning for UNION
systay Jul 7, 2023
e0b79bb
wip - start of merging UNION
systay Jul 8, 2023
78c7422
wip - continue with merging of UNION
systay Jul 12, 2023
6a3eeb6
wip - logic around turning UNION operators to SQL
systay Jul 12, 2023
616bfbe
logic around DISTINCT pushing
systay Jul 12, 2023
22d7f35
improved logic in Union.AddColumn
systay Jul 12, 2023
897089e
missing license header
systay Jul 12, 2023
efde977
don't remove operators by mistake
systay Jul 13, 2023
bce1ff8
merge UNION ALL as well
systay Jul 13, 2023
e478eaf
add FindCol to the Operator interface
systay Jul 13, 2023
5111b7f
create derived projection on top of union on horizon expansion
harshit-gangal Jul 14, 2023
613ff29
handle union columns in the semtable so dependencies are handled corr…
systay Jul 19, 2023
6eb1e87
make sure that UNION reports enough columns so column truncation can …
systay Jul 19, 2023
fed1124
handle types and dependencies better for UNIONs not in derived tables
systay Jul 19, 2023
07cf4f8
clean up Disinct operator handling
systay Jul 21, 2023
e284b57
instead of failing, we can use a Filter op instead
systay Jul 21, 2023
e9eac98
move from AddColumn to AddColumns
systay Jul 26, 2023
f939787
clean up projections around aggregation and derived tables
systay Jul 27, 2023
55c3738
distinct to send columns at once to source for AddColumns, route to a…
harshit-gangal Aug 2, 2023
054f78f
add truncation logic to filter
harshit-gangal Aug 2, 2023
b9278d2
fix the test expectation
harshit-gangal Aug 2, 2023
f5dd14b
update sizegen
harshit-gangal Aug 2, 2023
b173f8c
improve distinct planning to only reject when columns do not align
harshit-gangal Aug 2, 2023
d37cc71
update executor union query test expectation
harshit-gangal Aug 2, 2023
edcbc4f
fix compact and truncation order by reversing it and adding one more …
harshit-gangal Aug 2, 2023
ddc049e
merge sharded route on union only when both are scatter or both are e…
harshit-gangal Aug 3, 2023
364d3ad
fix unit test
harshit-gangal Aug 3, 2023
357d349
addressed review comments
harshit-gangal Aug 4, 2023
e5ee6bb
moved unsupported cases to unsupported_cases file
harshit-gangal Aug 6, 2023
b455e75
Merge remote-tracking branch 'upstream/main' into new-union-planning
harshit-gangal Aug 6, 2023
52299b3
remove optimization that lead to issues
systay Aug 7, 2023
885a94e
clean up distinct ws handling
systay Aug 7, 2023
6878101
no need to ask for the weightstring of a weightstring
systay Aug 7, 2023
41bdbf0
fix test in executor
harshit-gangal Aug 7, 2023
c10e4f5
no compact after truncation call
harshit-gangal Aug 7, 2023
9b19a24
calculate the dependencies more fine grained
systay Aug 7, 2023
6b4a544
remove unneeded projections
systay Aug 7, 2023
5abffd6
remove weightstring for literal values
systay Aug 7, 2023
2021206
remove any DISTINCTs we still have not pushed down
systay Aug 7, 2023
125145f
Merge remote-tracking branch 'upstream/main' into new-union-planning
harshit-gangal Aug 8, 2023
ff8d3f1
fix test query
harshit-gangal Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test in executor
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Aug 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 41bdbf03db1a753fdd881e4d8e627d15b1dcddbb
24 changes: 12 additions & 12 deletions go/vt/vtgate/executor_select_test.go
Original file line number Diff line number Diff line change
@@ -3642,15 +3642,15 @@ func TestSelectAggregationNoData(t *testing.T) {
},
{
sql: `select count(*) from (select col1, col2 from user limit 2) x`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1", "int64")),
expSandboxQ: "select 1 from (select col1, col2 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1|col2|1", "int64|int64|int64")),
expSandboxQ: "select col1, col2, 1 from (select col1, col2 from `user`) as x limit :__upper_limit",
expField: `[name:"count(*)" type:INT64]`,
expRow: `[[INT64(0)]]`,
},
{
sql: `select col2, count(*) from (select col1, col2 from user limit 2) x group by col2`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col2|1|weight_string(col2)", "int64|int64|varbinary")),
expSandboxQ: "select col2, 1, weight_string(col2) from (select col1, col2 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1|col2|1|weight_string(col2)", "int64|int64|int64|varbinary")),
expSandboxQ: "select col1, col2, 1, weight_string(col2) from (select col1, col2 from `user`) as x limit :__upper_limit",
expField: `[name:"col2" type:INT64 name:"count(*)" type:INT64]`,
expRow: `[]`,
},
@@ -3726,29 +3726,29 @@ func TestSelectAggregationData(t *testing.T) {
},
{
sql: `select count(*) from (select col1, col2 from user limit 2) x`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("1", "int64"), "1", "1"),
expSandboxQ: "select 1 from (select col1, col2 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1|col2|1", "int64|int64|int64"), "100|200|1", "200|300|1"),
expSandboxQ: "select col1, col2, 1 from (select col1, col2 from `user`) as x limit :__upper_limit",
expField: `[name:"count(*)" type:INT64]`,
expRow: `[[INT64(2)]]`,
},
{
sql: `select col2, count(*) from (select col1, col2 from user limit 9) x group by col2`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col2|1|weight_string(col2)", "int64|int64|varbinary"), "3|1|NULL", "2|1|NULL"),
expSandboxQ: "select col2, 1, weight_string(col2) from (select col1, col2 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1|col2|1|weight_string(col2)", "int64|int64|int64|varbinary"), "100|3|1|NULL", "200|2|1|NULL"),
expSandboxQ: "select col1, col2, 1, weight_string(col2) from (select col1, col2 from `user`) as x limit :__upper_limit",
expField: `[name:"col2" type:INT64 name:"count(*)" type:INT64]`,
expRow: `[[INT64(2) INT64(4)] [INT64(3) INT64(5)]]`,
},
{
sql: `select count(col1) from (select id, col1 from user limit 2) x`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1", "varchar"), "a", "b"),
expSandboxQ: "select col1 from (select id, col1 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("id|col1", "int64|varchar"), "1|a", "2|b"),
expSandboxQ: "select id, col1 from (select id, col1 from `user`) as x limit :__upper_limit",
expField: `[name:"count(col1)" type:INT64]`,
expRow: `[[INT64(2)]]`,
},
{
sql: `select count(col1), col2 from (select col2, col1 from user limit 9) x group by col2`,
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col1|col2|weight_string(col2)", "varchar|int64|varbinary"), "a|3|NULL", "b|2|NULL"),
expSandboxQ: "select col1, col2, weight_string(col2) from (select col2, col1 from `user`) as x limit :__upper_limit",
sandboxRes: sqltypes.MakeTestResult(sqltypes.MakeTestFields("col2|col1|weight_string(col2)", "int64|varchar|varbinary"), "3|a|NULL", "2|b|NULL"),
expSandboxQ: "select col2, col1, weight_string(col2) from (select col2, col1 from `user`) as x limit :__upper_limit",
expField: `[name:"count(col1)" type:INT64 name:"col2" type:INT64]`,
expRow: `[[INT64(4) INT64(2)] [INT64(5) INT64(3)]]`,
},