diff --git a/compiler/optimizer/pruner.go b/compiler/optimizer/pruner.go index 63bc9352b..96c3ccf92 100644 --- a/compiler/optimizer/pruner.go +++ b/compiler/optimizer/pruner.go @@ -138,13 +138,13 @@ func reverseComparator(op string) string { case "==", "!=": return op case "<": - return ">=" - case "<=": return ">" + case "<=": + return ">=" case ">": - return "<=" - case ">=": return "<" + case ">=": + return "<=" } panic("unknown op") } diff --git a/compiler/ztests/pruner.yaml b/compiler/ztests/pruner.yaml new file mode 100644 index 000000000..fdc9ea5e7 --- /dev/null +++ b/compiler/ztests/pruner.yaml @@ -0,0 +1,15 @@ +# Test pruner flips comparator with literal/path +script: | + super -f parquet -o test.parquet -c 'values {v:1}' + super compile -O -C -c 'from test.parquet | where 1 <= v and 1 >= v' + +outputs: + - name: stdout + data: | + file test.parquet format parquet filter (1<=v and 1>=v) + pruner ( + expr compare(v.max, 1, true)>=0 and compare(v.min, 1, true)<=0 + fields v.max,v.min + ) + | where 1<=v and 1>=v + | output main