Skip to content

Commit

Permalink
Enable use of slices in tuples for HashLookups
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 authored Sep 13, 2023
2 parents 0324aff + 56394e4 commit 3568fec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
20 changes: 20 additions & 0 deletions enginetest/join_op_tests.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 3568fec

Please sign in to comment.