File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,11 @@ func (n *Not) Eval(val vector.Any) vector.Any {
2727func (n * Not ) eval (vecs ... vector.Any ) vector.Any {
2828 switch vec := vecs [0 ].(type ) {
2929 case * vector.Bool :
30- return vector .NewBool ( bitvec . Not (vec . Bits ), vec . Nulls )
30+ return vector .Not (vec )
3131 case * vector.Const :
32+ if vec .Value ().IsNull () {
33+ return vec
34+ }
3235 return vector .NewConst (super .NewBool (! vec .Value ().Bool ()), vec .Len (), vec .Nulls )
3336 case * vector.Error :
3437 return vec
Original file line number Diff line number Diff line change @@ -15,3 +15,21 @@ output: |
1515 null::bool
1616 error("missing")
1717 error("foo")
18+
19+ ---
20+
21+ # Ensure true/null values are converted to false/null.
22+ spq : |
23+ values false or not this
24+
25+ vector : true
26+
27+ input : |
28+ true
29+ false
30+ null::bool
31+
32+ output : |
33+ false
34+ true
35+ null::bool
Original file line number Diff line number Diff line change @@ -64,6 +64,16 @@ func Or(a, b *Bool) *Bool {
6464 return NewBool (bits , nulls )
6565}
6666
67+ func Not (vec * Bool ) * Bool {
68+ bits := bitvec .Not (vec .Bits )
69+ if vec .Nulls .IsZero () {
70+ return NewBool (bits , bitvec .Zero )
71+ }
72+ // Flip true/null values to false/null.
73+ bits = bitvec .And (bits , bitvec .Not (vec .Nulls ))
74+ return NewBool (bits , vec .Nulls )
75+ }
76+
6777// BoolValue returns the value of slot in vec if the value is a Boolean. It
6878// returns false otherwise.
6979func BoolValue (vec Any , slot uint32 ) (bool , bool ) {
You can’t perform that action at this time.
0 commit comments