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

WIP: do not merge. test for order by which is incorrectly planned cross-shard #4542

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 78 additions & 0 deletions data/test/vtgate/postprocess_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,84 @@
}
}

# ORDER BY non-key column for join
"select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a"
{
"Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a",
"Instructions": {
"Opcode": "Join",
"Left": {
"Opcode": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc",
"FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1",
"Vindex": "user_index",
"Values": [1]
},
"Right": {
"Opcode": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "select music.col3 from music where music.id = :user_id",
"FieldQuery": "select music.col3 from music where 1 != 1",
"Vindex": "music_user_map",
"Values": [":user_id"]
},
"Cols": [
-1,
-2,
1
],
"Vars": {
"user_id": 2
}
}
}

# ORDER BY non-key column for implicit join
"select user.col1 as a, user.col2, music.col3 from user, music where user.id = music.id and user.id = 1 order by a"
{
"Original": "select user.col1 as a, user.col2, music.col3 from user, music where user.id = music.id and user.id = 1 order by a",
"Instructions": {
"Opcode": "Join",
"Left": {
"Opcode": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc",
"FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1",
"Vindex": "user_index",
"Values": [1]
},
"Right": {
"Opcode": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "select music.col3 from music where music.id = :user_id",
"FieldQuery": "select music.col3 from music where 1 != 1",
"Vindex": "music_user_map",
"Values": [":user_id"]
},
"Cols": [
-1,
-2,
1
],
"Vars": {
"user_id": 2
}
}
}

# ORDER BY NULL after pull-out subquery
"select col from user where col in (select col2 from user) order by null"
{
Expand Down
4 changes: 4 additions & 0 deletions data/test/vtgate/unsupported_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"select id from (select user.id, user.col from user join user_extra) as t order by id"
"unsupported: cannot order by on a cross-shard subquery"

# order by on a cross-shard query. Note: this is only a problem when an order by column is from the second table
"select user.col1 as a, user.col2 b, music.col3 c from user, music where user.id = music.id and user.id = 1 order by c"
"unsupported: order by spans across shards"

# scatter order by with * expression
"select * from user order by id"
"unsupported: in scatter query: order by must reference a column in the select list: id asc"
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func testFile(t *testing.T, filename string, vschema *vindexes.VSchema) {
out = string(bout)
}
if out != tcase.output {
t.Errorf("File: %s, Line:%v\n%s, want\n%s", filename, tcase.lineno, out, tcase.output)
t.Errorf("File: %s, Line:%v\n got:\n%s, \nwant:\n%s", filename, tcase.lineno, out, tcase.output)
// Uncomment these lines to re-generate input files
if err != nil {
out = fmt.Sprintf("\"%s\"", out)
Expand Down