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

Enable use of slices in tuples for HashLookups #2004

Merged
merged 2 commits into from Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions enginetest/join_op_tests.go
Expand Up @@ -123,6 +123,26 @@ var joinOpTests = []struct {
},
},
},
{
name: "left join on array data",
setup: [][]string{
{
"create table xy (x binary(2) primary key, y binary(2))",
"create table uv (u binary(2) primary key, v binary(2))",
"insert into xy values (x'F0F0',x'1234'),(x'2345',x'3456');",
"insert into uv values (x'fedc',x'F0F0');",
},
},
tests: []JoinOpTests{
{
Query: "select HEX(x),HEX(u) from xy left join uv on x = v OR y = u",
Expected: []sql.Row{
{"2345", nil},
{"F0F0", "FEDC"},
},
},
},
},
{
name: "point lookups",
setup: [][]string{
Expand Down
17 changes: 1 addition & 16 deletions sql/plan/hash_lookup.go
Expand Up @@ -132,22 +132,7 @@ func (n *HashLookup) GetHashKey(ctx *sql.Context, e sql.Expression, row sql.Row)
return nil, err
}
if s, ok := key.([]interface{}); ok {
switch len(s) {
case 0:
return [0]interface{}{}, nil
case 1:
return [1]interface{}{s[0]}, nil
case 2:
return [2]interface{}{s[0], s[1]}, nil
case 3:
return [3]interface{}{s[0], s[1], s[2]}, nil
case 4:
return [4]interface{}{s[0], s[1], s[2], s[3]}, nil
case 5:
return [5]interface{}{s[0], s[1], s[2], s[3], s[4]}, nil
default:
return sql.HashOf(s)
}
return sql.HashOf(s)
}
// byte slices are not hashable
if k, ok := key.([]byte); ok {
Expand Down