Skip to content

Commit 3568fec

Browse files
authored
Enable use of slices in tuples for HashLookups
2 parents 0324aff + 56394e4 commit 3568fec

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

enginetest/join_op_tests.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ var joinOpTests = []struct {
123123
},
124124
},
125125
},
126+
{
127+
name: "left join on array data",
128+
setup: [][]string{
129+
{
130+
"create table xy (x binary(2) primary key, y binary(2))",
131+
"create table uv (u binary(2) primary key, v binary(2))",
132+
"insert into xy values (x'F0F0',x'1234'),(x'2345',x'3456');",
133+
"insert into uv values (x'fedc',x'F0F0');",
134+
},
135+
},
136+
tests: []JoinOpTests{
137+
{
138+
Query: "select HEX(x),HEX(u) from xy left join uv on x = v OR y = u",
139+
Expected: []sql.Row{
140+
{"2345", nil},
141+
{"F0F0", "FEDC"},
142+
},
143+
},
144+
},
145+
},
126146
{
127147
name: "point lookups",
128148
setup: [][]string{

sql/plan/hash_lookup.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,7 @@ func (n *HashLookup) GetHashKey(ctx *sql.Context, e sql.Expression, row sql.Row)
132132
return nil, err
133133
}
134134
if s, ok := key.([]interface{}); ok {
135-
switch len(s) {
136-
case 0:
137-
return [0]interface{}{}, nil
138-
case 1:
139-
return [1]interface{}{s[0]}, nil
140-
case 2:
141-
return [2]interface{}{s[0], s[1]}, nil
142-
case 3:
143-
return [3]interface{}{s[0], s[1], s[2]}, nil
144-
case 4:
145-
return [4]interface{}{s[0], s[1], s[2], s[3]}, nil
146-
case 5:
147-
return [5]interface{}{s[0], s[1], s[2], s[3], s[4]}, nil
148-
default:
149-
return sql.HashOf(s)
150-
}
135+
return sql.HashOf(s)
151136
}
152137
// byte slices are not hashable
153138
if k, ok := key.([]byte); ok {

0 commit comments

Comments
 (0)