Skip to content

Commit

Permalink
Fixed up tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Jul 14, 2021
1 parent 847b0ec commit bea8ef6
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
102 changes: 101 additions & 1 deletion go/vt/vtgate/planbuilder/testdata/aggr_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,60 @@ Gen4 plan same as above
]
}
}
{
"QueryType": "SELECT",
"Original": "select col, count(*) from user group by col",
"Instructions": {
"OperatorType": "Aggregate",
"Variant": "Ordered",
"Aggregates": "count(1)",
"GroupBy": "(0|2)",
"ResultColumns": 2,
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select col, count(*), weight_string(col) from `user` where 1 != 1 group by col",
"OrderBy": "(0|2) ASC",
"Query": "select col, count(*), weight_string(col) from `user` group by col order by col asc",
"Table": "`user`"
}
]
}
}

# group by must only reference expressions in the select list
"select col, count(*) from user group by col, baz"
"unsupported: in scatter query: group by column must reference column in SELECT list"
{
"QueryType": "SELECT",
"Original": "select col, count(*) from user group by col, baz",
"Instructions": {
"OperatorType": "Aggregate",
"Variant": "Ordered",
"Aggregates": "count(1)",
"GroupBy": "(0|2), (3|4)",
"ResultColumns": 2,
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select col, count(*), weight_string(col), baz, weight_string(baz) from `user` where 1 != 1 group by col, baz",
"OrderBy": "(0|2) ASC, (3|4) ASC",
"Query": "select col, count(*), weight_string(col), baz, weight_string(baz) from `user` group by col, baz order by col asc, baz asc",
"Table": "`user`"
}
]
}
}

# group by a non-unique vindex column should use an OrderedAggregate primitive
"select name, count(*) from user group by name"
Expand Down Expand Up @@ -966,7 +1016,7 @@ Gen4 plan same as above
}

# scatter aggregate group by aggregate function
" select count(*) b from user group by b"
"select count(*) b from user group by b"
"Can't group on 'b'"

# scatter aggregate multiple group by (columns)
Expand Down Expand Up @@ -996,6 +1046,31 @@ Gen4 plan same as above
]
}
}
{
"QueryType": "SELECT",
"Original": "select a, b, count(*) from user group by b, a",
"Instructions": {
"OperatorType": "Aggregate",
"Variant": "Ordered",
"Aggregates": "count(2)",
"GroupBy": "(1|3), (0|4)",
"ResultColumns": 3,
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select a, b, count(*), weight_string(b), weight_string(a) from `user` where 1 != 1 group by b, a",
"OrderBy": "(1|3) ASC, (0|4) ASC",
"Query": "select a, b, count(*), weight_string(b), weight_string(a) from `user` group by b, a order by b asc, a asc",
"Table": "`user`"
}
]
}
}

# scatter aggregate multiple group by (numbers)
"select a, b, count(*) from user group by 2, 1"
Expand Down Expand Up @@ -1024,6 +1099,31 @@ Gen4 plan same as above
]
}
}
{
"QueryType": "SELECT",
"Original": "select a, b, count(*) from user group by 2, 1",
"Instructions": {
"OperatorType": "Aggregate",
"Variant": "Ordered",
"Aggregates": "count(2)",
"GroupBy": "(1|3), (0|4)",
"ResultColumns": 3,
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select a, b, count(*), weight_string(b), weight_string(a) from `user` where 1 != 1 group by b, a",
"OrderBy": "(1|3) ASC, (0|4) ASC",
"Query": "select a, b, count(*), weight_string(b), weight_string(a) from `user` group by b, a order by b asc, a asc",
"Table": "`user`"
}
]
}
}

# scatter aggregate multiple group by columns inverse order
"select a, b, count(*) from user group by b, a"
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/testdata/select_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ Gen4 plan same as above
"select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n'"
{
"QueryType": "SELECT",
"Original": "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\\n'",
"Original": "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n'",
"Instructions": {
"OperatorType": "Route",
"Variant": "SelectUnsharded",
Expand All @@ -1627,7 +1627,7 @@ Gen4 plan same as above
"select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off"
{
"QueryType": "SELECT",
"Original": "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\\n' manifest on overwrite off",
"Original": "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off",
"Instructions": {
"OperatorType": "Route",
"Variant": "SelectUnsharded",
Expand Down

0 comments on commit bea8ef6

Please sign in to comment.