Skip to content

Commit

Permalink
fix inverted index IN filter error (#1146)
Browse files Browse the repository at this point in the history
* fix inverted index IN filter error

* delete stale error
  • Loading branch information
max-hoffman authored Aug 2, 2022
1 parent 2a7d7d5 commit 70f368b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions enginetest/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -6766,6 +6766,10 @@ var QueryTests = []QueryTest{
Query: `select * from mytable where 1 = 0 order by i asc`,
Expected: []sql.Row{},
},
{
Query: `select * from mytable where i not in (1)`,
Expected: []sql.Row{{2, "second row"}, {3, "third row"}},
},
}

var KeylessQueries = []QueryTest{
Expand Down
13 changes: 6 additions & 7 deletions sql/analyzer/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
package analyzer

import (
errors "gopkg.in/src-d/go-errors.v1"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
"github.com/dolthub/go-mysql-server/sql/plan"
)

var errInvalidInRightEvaluation = errors.NewKind("expecting evaluation of IN expression right hand side to be a tuple, but it is %T")

// indexLookup contains an sql.IndexLookup and all sql.Index that are involved
// in it.
type indexLookup struct {
Expand Down Expand Up @@ -449,9 +445,12 @@ func getNegatedIndexes(
return nil, err
}

values, ok := value.([]interface{})
if !ok {
return nil, errInvalidInRightEvaluation.New(value)
var values []interface{}
switch v := value.(type) {
case []interface{}:
values = v
default:
values = []interface{}{v}
}

idxBuilder := sql.NewIndexBuilder(ctx, idx)
Expand Down

0 comments on commit 70f368b

Please sign in to comment.