brimdata / super

A novel data lake based on super-structured data
https://zed.brimdata.io/
BSD 3-Clause "New" or "Revised" License
1.39k stars 64 forks source link

nest_dotted function panics on non-record value #5241

Open philrz opened 2 months ago

philrz commented 2 months ago

Repro is with Zed commit 48021d7.

The nest_dotted function docs set expectations that it's only intended to be used on records, so I'm not surprised this failed. But a panic and stack dump is undesirable.

$ zq -version
Version: v1.17.0-35-g48021d77

$ echo '"Hello"' | zq -z 'yield nest_dotted(this)' -
panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
runtime/debug.Stack()
    /usr/local/opt/go@1.21/libexec/src/runtime/debug/stack.go:24 +0x5e
github.com/brimdata/zed/runtime/sam/op.(*Catcher).Pull.func1()
    /Users/phil/work/zed/runtime/sam/op/catcher.go:25 +0x3d
panic({0x24b2660?, 0x376df50?})
    /usr/local/opt/go@1.21/libexec/src/runtime/panic.go:914 +0x21f
github.com/brimdata/zed.(*TypeRecord).ID(...)
    /Users/phil/work/zed/complex.go:215
github.com/brimdata/zed/runtime/sam/expr/function.(*NestDotted).lookupBuilderAndType(0xc000012f18, 0x0)
    /Users/phil/work/zed/runtime/sam/expr/function/nestdotted.go:32 +0x2e
github.com/brimdata/zed/runtime/sam/expr/function.(*NestDotted).Call(0xc000012f18, {0x298c928, 0xc000525d80}, {0xc000116300?, 0xc0005278a0?, 0x0?})
    /Users/phil/work/zed/runtime/sam/expr/function/nestdotted.go:61 +0x189
github.com/brimdata/zed/runtime/sam/expr.(*Call).Eval(0xc000175280, {0x298c928, 0xc000525d80}, {0x2986700?, 0xc00041f7a8?})
    /Users/phil/work/zed/runtime/sam/expr/eval.go:752 +0xce
github.com/brimdata/zed/runtime/sam/op/yield.(*Op).Pull(0xc0001752c0, 0x37?)
    /Users/phil/work/zed/runtime/sam/op/yield/yield.go:36 +0x4e8
github.com/brimdata/zed/runtime/sam/op.(*Single).Pull(0xc000515a10, 0xf4)
    /Users/phil/work/zed/runtime/sam/op/mux.go:120 +0x33
github.com/brimdata/zed/runtime/sam/op.(*Catcher).Pull(0xc000680000?, 0xd8?)
    /Users/phil/work/zed/runtime/sam/op/catcher.go:28 +0x62
github.com/brimdata/zed/runtime/exec.(*Query).Pull(0xc000680000?, 0x60?)
    /Users/phil/work/zed/runtime/exec/query.go:59 +0x3e
github.com/brimdata/zed/zbuf.CopyMux(0x2494ac0?, {0x2986200, 0xc000515a40})
    /Users/phil/work/zed/zbuf/mux.go:40 +0x38
github.com/brimdata/zed/cli/zq.(*Command).Run(0xc0004da1e0, {0xc0000400a0, 0x2, 0x2})
    /Users/phil/work/zed/cli/zq/command.go:168 +0x9c5
github.com/brimdata/zed/pkg/charm.path.run({0xc0007202f8?, 0x1, 0x1}, {0xc0000400a0?, 0x2, 0x0?})
    /Users/phil/work/zed/pkg/charm/path.go:11 +0x79
github.com/brimdata/zed/pkg/charm.(*Spec).ExecRoot(0x100874b?, {0xc000040090, 0x3, 0x3})
    /Users/phil/work/zed/pkg/charm/charm.go:63 +0x3f
main.main()
    /Users/phil/work/zed/cmd/zq/main.go:11 +0x5b
philrz commented 1 month ago

@mattnibs noted that he's likely to take up vectorized nest_dotted soon and hence might be able to fix this at the same time.