Make sure that outOfRange field predicates return not-null for NEQ queries

This commit is contained in:
Travis 2017-10-06 14:47:56 -05:00
parent d62ea053b5
commit b0afec0761
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
2 changed files with 13 additions and 1 deletions

View file

@ -794,7 +794,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c *
}
baseValue, outOfRange := field.BaseValue(cond.Op, value)
if outOfRange {
if outOfRange && cond.Op != pql.NEQ {
return NewBitmap(), nil
}
@ -804,6 +804,11 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c *
return NewBitmap(), nil
}
// outOfRange for NEQ should return all not-null.
if outOfRange && cond.Op == pql.NEQ {
return frag.FieldNotNull(field.BitDepth())
}
f.Stats.Count("range:field", 1, 1.0)
return frag.FieldRange(cond.Op, field.BitDepth(), baseValue)
}

View file

@ -777,6 +777,13 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
} else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1, SliceWidth + 2}, result[0].(*pilosa.Bitmap).Bits()) {
t.Fatalf("unexpected result: %s", spew.Sdump(result))
}
// NEQ -<int>
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo != -20)`), nil, nil); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Bitmap).Bits()) {
//t.Fatalf("unexpected result: %s", spew.Sdump(result))
t.Fatalf("unexpected result: %s", result[0].(*pilosa.Bitmap).Bits())
}
})
t.Run("LT", func(t *testing.T) {