-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Labels
Description
When the following query is executed in vector runtime it gives an error("divide by zero"), but per SQL conventions it should return NULL.
$ SUPER_VAM=1 super -c "SELECT 1 / CAST ( NULL AS INTEGER );"
{"1/CAST( AS int32)":error("divide by zero")}
Details
Repro is with super commit 30f64bb. This is a simplification of a query from a sqllogictest (aka random/aggregates/slt_good_76/q3497).
Here's the expected result in sequential runtime and Postgres.
$ super -version
Version: 30f64bbac
$ super -c "SELECT 1 / CAST ( NULL AS INTEGER );"
{"1/CAST( AS int32)":null::int64}
$ psql postgres
psql (17.7 (Homebrew), server 17.6 (Homebrew))
Type "help" for help.
postgres=# \pset null 'NULL'
Null display is "NULL".
postgres=# SELECT 1 / CAST ( NULL AS INTEGER );
?column?
----------
NULL
(1 row)
When the original sqllogictest was executed in vector runtime it actually manifested as a panic, but the error("divide by zero") revealed itself as I simplified the query.
$ SUPER_VAM=1 super -c "SELECT + 95 * + + 3 + - CAST ( 49 + 61 / + CAST ( NULL AS INTEGER ) AS INTEGER ) AS col1 FROM tab0 AS cor0;"
panic: &{Typ:0xc000446948 Vals:0xc0000f6e60 Nulls:empty}
goroutine 1 [running]:
runtime/debug.Stack()
/usr/local/opt/go/libexec/src/runtime/debug/stack.go:26 +0x5e
github.com/brimdata/super/runtime/sam/op.(*Catcher).Pull.func1()
/Users/phil/work/super/runtime/sam/op/catcher.go:25 +0x3d
panic({0x8703240?, 0xc00044d180?})
/usr/local/opt/go/libexec/src/runtime/panic.go:783 +0x132
github.com/brimdata/super/runtime/vam/expr/cast.toNumeric[...]({0x894bdf0?, 0xc00044d180?}, {0x8940818?, 0x9af8960?}, {0x0?, 0x0?, 0x4?})
/Users/phil/work/super/runtime/vam/expr/cast/number.go:85 +0x4d6
github.com/brimdata/super/runtime/vam/expr/cast.castToNumber({0x894bdf0, 0xc00044d180}, {0x8940818, 0x9af8960}, {0x0, 0x0, 0x0})
/Users/phil/work/super/runtime/vam/expr/cast/number.go:31 +0x3d5
github.com/brimdata/super/runtime/vam/expr/cast.To.func1({0x894bdf0?, 0xc00044d180?}, {0x0?, 0x894bdf0?, 0xc00044d180?})
/Users/phil/work/super/runtime/vam/expr/cast/cast.go:17 +0x39
github.com/brimdata/super/runtime/vam/expr/cast.assemble(0xc000452990, {0x894bdf0, 0xc00044d180}, {0x8940818, 0x9af8960}, 0x8801480?)
/Users/phil/work/super/runtime/vam/expr/cast/cast.go:66 +0x44c
github.com/brimdata/super/runtime/vam/expr/cast.To(0xc000452990, {0x894bdf0?, 0xc00044d180?}, {0x8940818, 0x9af8960})
/Users/phil/work/super/runtime/vam/expr/cast/cast.go:39 +0x17c
github.com/brimdata/super/runtime/vam/expr.(*casterPrimitive).Eval(0x69569f4?, {0x894bdf0?, 0xc00044d180?})
/Users/phil/work/super/runtime/vam/expr/cast.go:54 +0x2b
github.com/brimdata/super/runtime/vam/expr.(*literalCast).Eval.func1({0xc00059e120?, 0x507a2aa0?, 0x9cad108?})
/Users/phil/work/super/runtime/vam/expr/cast.go:44 +0x33
github.com/brimdata/super/vector.Apply(0x0?, 0x894bdf0?, {0xc00059e120?, 0xc000057538?, 0x87031c0?})
/Users/phil/work/super/vector/apply.go:19 +0xf3
github.com/brimdata/super/vector.Apply-range1(...)
/Users/phil/work/super/vector/apply.go:24
github.com/brimdata/super/vector.Apply.rip.func1(...)
/Users/phil/work/super/vector/apply.go:52
github.com/brimdata/super/vector.Apply(0x1, 0xc0000575d0, {0xc00059e110?, 0x6957425?, 0x20?})
/Users/phil/work/super/vector/apply.go:22 +0x185
github.com/brimdata/super/runtime/vam/expr.(*literalCast).Eval(0xc00036e020, {0x894c150?, 0xc0000f6aa0?})
/Users/phil/work/super/runtime/vam/expr/cast.go:43 +0x9e
github.com/brimdata/super/runtime/vam/expr.(*unaryMinus).Eval(0xc000447500, {0x894c150?, 0xc0000f6aa0?})
/Users/phil/work/super/runtime/vam/expr/unaryminus.go:22 +0x2f
github.com/brimdata/super/runtime/vam/expr.(*Arith).Eval(0xc0001cf590, {0x894c150, 0xc0000f6aa0})
/Users/phil/work/super/runtime/vam/expr/arith.go:28 +0x56
github.com/brimdata/super/runtime/vam/expr.(*recordExpr).Eval(0xc000032e00, {0x894c150, 0xc0000f6aa0})
/Users/phil/work/super/runtime/vam/expr/recordexpr.go:39 +0x1a2
github.com/brimdata/super/runtime/vam/op.(*Values).Pull(0xc0001cf5f0, 0x0)
/Users/phil/work/super/runtime/vam/op/yield.go:34 +0x10c
github.com/brimdata/super/runtime/vam.(*Materializer).Pull(0x9cb6e90?, 0xd0?)
/Users/phil/work/super/runtime/vam/materialize.go:26 +0x27
github.com/brimdata/super/runtime/sam/op.(*Single).Pull(0xc0001cf650, 0x10?)
/Users/phil/work/super/runtime/sam/op/mux.go:120 +0x33
github.com/brimdata/super/runtime/sam/op.(*Catcher).Pull(0x5dd0b09885d33ff7?, 0xa5?)
/Users/phil/work/super/runtime/sam/op/catcher.go:28 +0x5c
github.com/brimdata/super/runtime/exec.(*Query).Pull(0x6953a3f?, 0xe0?)
/Users/phil/work/super/runtime/exec/query.go:49 +0x3c
github.com/brimdata/super/sbuf.CopyMux(0xc000057d10, {0x8938220, 0xc0001cf6e0})
/Users/phil/work/super/sbuf/mux.go:39 +0x38
github.com/brimdata/super/cmd/super/root.(*Command).Run(0xc0004666c8, {0xc00012c8c0, 0x0, 0x0})
/Users/phil/work/super/cmd/super/root/command.go:166 +0xa27
github.com/brimdata/super/pkg/charm.path.run({0xc0001302e8, 0x1, 0x1}, {0xc00012c8c0, 0x0, 0x0?})
/Users/phil/work/super/pkg/charm/path.go:11 +0x7b
github.com/brimdata/super/pkg/charm.(*Spec).Exec(0x9abd300, {0xc00012c8b0, 0x2, 0x2})
/Users/phil/work/super/pkg/charm/charm.go:74 +0x1fa
main.main()
/Users/phil/work/super/cmd/super/main.go:39 +0x5b