mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Merge pull request #1822 from travisturner/range-between-bug
fixes a bug on upper end of bsi range queries
This commit is contained in:
commit
01f54c1f70
3 changed files with 42 additions and 14 deletions
|
|
@ -1901,16 +1901,44 @@ func TestExecutor_Execute_Row_BSIGroup(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("BETWEEN", func(t *testing.T) {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Row(0 < other < 1000)`}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
tests := []struct {
|
||||
q string
|
||||
exp bool
|
||||
}{
|
||||
{q: `Row(0 < other < 1000)`, exp: false},
|
||||
{q: `Row(0 <= other < 1000)`, exp: false},
|
||||
{q: `Row(0 <= other <= 1000)`, exp: true},
|
||||
{q: `Row(0 < other <= 1000)`, exp: true},
|
||||
|
||||
{q: `Row(1000 < other < 1000)`, exp: false},
|
||||
{q: `Row(1000 <= other < 1000)`, exp: false},
|
||||
{q: `Row(1000 <= other <= 1000)`, exp: true},
|
||||
{q: `Row(1000 < other <= 1000)`, exp: false},
|
||||
|
||||
{q: `Row(1000 < other < 2000)`, exp: false},
|
||||
{q: `Row(1000 <= other < 2000)`, exp: true},
|
||||
{q: `Row(1000 <= other <= 2000)`, exp: true},
|
||||
{q: `Row(1000 < other <= 2000)`, exp: false},
|
||||
}
|
||||
for i, test := range tests {
|
||||
t.Run(fmt.Sprintf("#%d_%s", i, test.q), func(t *testing.T) {
|
||||
var expected = []uint64{}
|
||||
if test.exp {
|
||||
expected = []uint64{0}
|
||||
}
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: test.q}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(expected, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result for query: %s", test.q)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// Ensure that the NotNull code path gets run.
|
||||
t.Run("NotNull", func(t *testing.T) {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Row(-1 < other < 1000)`}); err != nil {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Row(0 <= other <= 1000)`}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
|
|
@ -2069,14 +2097,14 @@ func TestExecutor_Execute_Range_BSIGroup_Deprecated(t *testing.T) {
|
|||
t.Run("BETWEEN", func(t *testing.T) {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Range(0 < other < 1000)`}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
} else if !reflect.DeepEqual([]uint64{}, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
||||
// Ensure that the NotNull code path gets run.
|
||||
t.Run("NotNull", func(t *testing.T) {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Range(-1 < other < 1000)`}); err != nil {
|
||||
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Range(0 <= other <= 1000)`}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result.Results[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ func (q *Query) endConditional() {
|
|||
if q.conditional[1] == "<" {
|
||||
low++
|
||||
}
|
||||
if q.conditional[3] == "<=" {
|
||||
high++
|
||||
if q.conditional[3] == "<" {
|
||||
high--
|
||||
}
|
||||
|
||||
elem := q.lastCallStackElem()
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ func TestPQLDeepEquality(t *testing.T) {
|
|||
Args: map[string]interface{}{
|
||||
"a": &Condition{
|
||||
Op: BETWEEN,
|
||||
Value: []interface{}{int64(4), int64(9)},
|
||||
Value: []interface{}{int64(4), int64(8)},
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
|
@ -513,7 +513,7 @@ func TestPQLDeepEquality(t *testing.T) {
|
|||
Args: map[string]interface{}{
|
||||
"a": &Condition{
|
||||
Op: BETWEEN,
|
||||
Value: []interface{}{int64(5), int64(9)},
|
||||
Value: []interface{}{int64(5), int64(8)},
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
|
@ -525,7 +525,7 @@ func TestPQLDeepEquality(t *testing.T) {
|
|||
Args: map[string]interface{}{
|
||||
"a": &Condition{
|
||||
Op: BETWEEN,
|
||||
Value: []interface{}{int64(4), int64(10)},
|
||||
Value: []interface{}{int64(4), int64(9)},
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
|
@ -537,7 +537,7 @@ func TestPQLDeepEquality(t *testing.T) {
|
|||
Args: map[string]interface{}{
|
||||
"a": &Condition{
|
||||
Op: BETWEEN,
|
||||
Value: []interface{}{int64(5), int64(10)},
|
||||
Value: []interface{}{int64(5), int64(9)},
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
|
@ -640,7 +640,7 @@ func TestPQLDeepEquality(t *testing.T) {
|
|||
Args: map[string]interface{}{
|
||||
"a": &Condition{
|
||||
Op: BETWEEN,
|
||||
Value: []interface{}{int64(5), int64(9)},
|
||||
Value: []interface{}{int64(5), int64(8)},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue