Skip to content

Commit

Permalink
fix case insensitive column match in kv iter (#8296)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor authored Aug 26, 2024
1 parent f592150 commit 849e099
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.18.2-0.20240821214223-afa83f4a1795
github.com/dolthub/go-mysql-server v0.18.2-0.20240826213655-024a764d305f
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e h1:kPsT4a47cw1+y/N5SSCkma7FhAPw7KeGmD6c9PBZW9Y=
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
github.com/dolthub/go-mysql-server v0.18.2-0.20240821214223-afa83f4a1795 h1:srMQ4T4IWDVmNVzwURgyGWoFGwDBlk0591TSltLuOdI=
github.com/dolthub/go-mysql-server v0.18.2-0.20240821214223-afa83f4a1795/go.mod h1:nbdOzd0ceWONE80vbfwoRBjut7z3CIj69ZgDF/cKuaA=
github.com/dolthub/go-mysql-server v0.18.2-0.20240826213655-024a764d305f h1:veiMzylffumQ1XX4vYuyk/iXV06o7CgDTY+YrQxtfNY=
github.com/dolthub/go-mysql-server v0.18.2-0.20240826213655-024a764d305f/go.mod h1:nbdOzd0ceWONE80vbfwoRBjut7z3CIj69ZgDF/cKuaA=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
9 changes: 8 additions & 1 deletion go/libraries/doltcore/sqle/kvexec/lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"io"
"strings"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
Expand Down Expand Up @@ -232,7 +233,10 @@ func newLookupKeyMapping(ctx context.Context, sourceSch schema.Schema, src proll
switch e := e.(type) {
case *expression.GetField:
// map the schema order index to the physical storage index
col := sourceSch.GetAllCols().NameToCol[e.Name()]
col, ok := sourceSch.GetAllCols().LowerNameToCol[strings.ToLower(e.Name())]
if !ok {
return nil
}
if col.IsPartOfPK {
srcMapping[i] = sourceSch.GetPKCols().TagToIdx[col.Tag]
} else if keyless {
Expand Down Expand Up @@ -274,6 +278,9 @@ func newLookupKeyMapping(ctx context.Context, sourceSch schema.Schema, src proll
// valid returns whether the source and destination key types
// are type compatible
func (m *lookupMapping) valid() bool {
if m == nil {
return false
}
var litIdx int
for to := range m.srcMapping {
from := m.srcMapping.MapOrdinal(to)
Expand Down
9 changes: 9 additions & 0 deletions go/libraries/doltcore/sqle/kvexec/lookup_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ func TestLookupJoin(t *testing.T) {
join: "select /*+ LOOKUP_JOIN(xy,ab) */ * from xy join ab on x = a where b = 1 and y = 1",
doRowexec: true,
},
{
name: "accept keys of different casing",
setup: []string{
"create table t1 (abc int primary key, def int)",
"create table t2 (GHI int primary key, JKL int)",
},
join: "select /*+ LOOKUP_JOIN(t1,t2) */ * from t1 join t2 on ABC = ghi",
doRowexec: true,
},
{
name: "reject type incompatibility",
setup: []string{
Expand Down

0 comments on commit 849e099

Please sign in to comment.