Skip to content

Commit 8b770c0

Browse files
committed
Fix null comparable issue
1 parent eee3d4e commit 8b770c0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

parser/ast.go

+16
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ func (e *ComparisonExpr) Evaluate(cols []string, row value.Row) (bool, error) {
7979
return true, nil
8080
}
8181
val := row[idx]
82+
if _, ok := val.(value.Null); ok {
83+
if _, iok := e.Right.(value.Null); iok {
84+
if e.Operator == "=" {
85+
return true, nil
86+
}
87+
return false, nil
88+
}
89+
return false, nil
90+
}
91+
// left is not null
92+
if _, ok := e.Right.(value.Null); ok {
93+
if e.Operator == "!=" {
94+
return true, nil
95+
}
96+
return false, nil
97+
}
8298
if !value.IsComparable(val, e.Right) {
8399
return false, fmt.Errorf("%s: %t and %t are not comparable", e.Left, val, e.Right)
84100
}

value/value.go

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ type Int96 struct {
204204

205205
func NewFromParquetValue(v interface{}) Value {
206206
switch v.(type) {
207+
case nil:
208+
return Null{}
207209
case int:
208210
return Int{Val: int64(v.(int))}
209211
case int8:

0 commit comments

Comments
 (0)