diff --git a/runtime/sam/expr/function/compare.go b/runtime/sam/expr/function/compare.go index 5905ba10e8..e3b165416f 100644 --- a/runtime/sam/expr/function/compare.go +++ b/runtime/sam/expr/function/compare.go @@ -28,6 +28,12 @@ func (e *Compare) Call(_ super.Allocator, args []super.Value) super.Value { } nullsMax = args[2].Bool() } + if args[0].IsError() { + return args[0] + } + if args[1].IsError() { + return args[1] + } cmp := e.nullsMax if !nullsMax { cmp = e.nullsMin diff --git a/runtime/sam/expr/function/ztests/compare.yaml b/runtime/sam/expr/function/ztests/compare.yaml index 5ac5a44948..147f5a988c 100644 --- a/runtime/sam/expr/function/ztests/compare.yaml +++ b/runtime/sam/expr/function/ztests/compare.yaml @@ -5,9 +5,13 @@ input: | {a: 2, b: "1"} {a: null, b: 2} {a: 0, b: 0.} + {a: 0} + {b: 0} output: | 1 -1 1 0 + error("missing") + error("missing")