$ super -version &&
git clone https://github.com/reverentgeek/duckdb-json-tutorial &&
cd duckdb-json-tutorial &&
super -c "
let samples = (from samples.json | unnest this)
let ducks = (from ducks.json | unnest this)
SELECT ducks.firstName || ' ' || ducks.lastName AS duck_name,
samples.action,
COUNT(*) AS observations
FROM samples
JOIN ducks
ON ducks.id = samples.id
GROUP BY duck_name, samples.action
ORDER BY 1, 3 DESC;"
Version: v0.3.0-139-gf5972950e
...
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/brimdata/super/compiler/optimizer.firstThisPathComponent.func1({{0xe780864, 0x8}, {0x0, 0x0, 0x0}})
/Users/phil/work/super/compiler/optimizer/join.go:165 +0x119
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xff2e9a0, 0x1e1d803a3a40?, 0x1?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:858 +0x315
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe670c0, 0x1e1d803a3a40?, 0x1e1d803a3ad0?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe66e40, 0x1e1d803905d0?, 0x1?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]-range1({0xfe66e40?, 0x1e1d803905d0?, 0x30?})
/Users/phil/work/super/compiler/optimizer/optimizer.go:853 +0x53
reflect.Value.Fields.func1(0x1e1d8031c1a0)
/usr/local/opt/go/libexec/src/reflect/value.go:2651 +0x182
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xff2eb80, 0x1e1d803905c0?, 0x18?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:852 +0x186
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe14d20, 0x1e1d803905c0?, 0x2?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe66f40, 0x1e1d803905f0?, 0x1e1d8041eba8?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfd9aec0, 0x1e1d803a3a88?, 0x1?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:847 +0x414
github.com/brimdata/super/compiler/optimizer.walkT[...]-range1({0xfd9aec0?, 0x1e1d803a3a88?, 0x30?})
/Users/phil/work/super/compiler/optimizer/optimizer.go:853 +0x53
reflect.Value.Fields.func1(0x1e1d8031c140)
/usr/local/opt/go/libexec/src/reflect/value.go:2651 +0x182
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xff87020, 0x1e1d803a3a70?, 0x1e1d803a3b30?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:852 +0x186
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe14a80, 0x1e1d803a3a70?, 0xcd2f770?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe66e40, 0x1e1d803a3ab0?, 0x1?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.walkT[...]-range1({0xfe66e40?, 0x1e1d803a3ab0?, 0x30?})
/Users/phil/work/super/compiler/optimizer/optimizer.go:853 +0x53
reflect.Value.Fields.func1(0x1e1d8031c120)
/usr/local/opt/go/libexec/src/reflect/value.go:2651 +0x182
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xff86a20, 0x1e1d803a3aa0?, 0xfe13760?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:852 +0x186
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe13c40, 0x1e1d803a3aa0?, 0x1e1d80092e60?}, 0x1e1d80399c20?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:850 +0x1f4
github.com/brimdata/super/compiler/optimizer.firstThisPathComponent({0x1013a6e0, 0x1e1d803a3aa0})
/Users/phil/work/super/compiler/optimizer/join.go:163 +0x105
github.com/brimdata/super/compiler/optimizer.equiJoinKeyExprs({0x1013a700?, 0x1e1d8038a780?}, {0xe7770a4, 0x4}, {0xe7787d3, 0x5})
/Users/phil/work/super/compiler/optimizer/join.go:137 +0x9c
github.com/brimdata/super/compiler/optimizer.replaceJoinWithHashJoin.func1({0x1013a440, 0x1e1d802fc370})
/Users/phil/work/super/compiler/optimizer/join.go:90 +0x12c
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfe66f40, 0x1e1d7fe9c410?, 0x1e1d8041f6e8?}, 0x10120298?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:858 +0x265
github.com/brimdata/super/compiler/optimizer.walkT[...]({0xfd9aec0, 0x1e1d80399a70?, 0xfd9aec0?}, 0x10120298?)
/Users/phil/work/super/compiler/optimizer/optimizer.go:847 +0x309
github.com/brimdata/super/compiler/optimizer.replaceJoinWithHashJoin({0x1e1d7fe9c400?, 0x8?, 0x10?})
/Users/phil/work/super/compiler/optimizer/join.go:83 +0x4e
github.com/brimdata/super/compiler/optimizer.(*Optimizer).Optimize(0x1e1d8041f7e8, 0x1e1d802fc460)
/Users/phil/work/super/compiler/optimizer/optimizer.go:129 +0x90
github.com/brimdata/super/compiler.Optimize({0x1015a4c0?, 0x1e1d803a2c60?}, 0x1e1d802fc460, 0x1e1d803a4600?, 0xc)
/Users/phil/work/super/compiler/package.go:32 +0x66
github.com/brimdata/super/compiler.CompileWithAST(0x1e1d803a2c60, 0xce23205?, 0x1e1d803a4600, 0x1, 0xc, {0x0, 0x0, 0x0})
/Users/phil/work/super/compiler/package.go:71 +0xa5
github.com/brimdata/super/compiler.(*compiler).NewQuery(0x1015a568?, 0x1e1d8030e640?, 0x1e1d80273918?, {0x0?, 0x48?, 0x10052200?}, 0x1e1d80273918?)
/Users/phil/work/super/compiler/compiler.go:42 +0x45
github.com/brimdata/super/runtime.CompileQuery({0x1015a568?, 0x1e1d8030e640?}, 0x1e1d802fdd60, {0x10144140, 0x1e1d7fe820b8}, 0x1e1d80391bc0, {0x0, 0x0, 0x0})
/Users/phil/work/super/runtime/compiler.go:32 +0x10f
github.com/brimdata/super/cmd/super/root.(*Command).Run(0x1e1d80096488, {0x1e1d7fdee710, 0x0, 0x0})
/Users/phil/work/super/cmd/super/root/command.go:96 +0x5ef
github.com/brimdata/super/pkg/charm.path.run({0x1e1d80402160, 0x1, 0x1}, {0x1e1d7fdee710, 0x0, 0x0?})
/Users/phil/work/super/pkg/charm/path.go:11 +0x7b
github.com/brimdata/super/pkg/charm.(*Spec).Exec(0x103f69e0, {0x1e1d7fdee700, 0x2, 0x2})
/Users/phil/work/super/pkg/charm/charm.go:74 +0x1fa
main.main()
/Users/phil/work/super/cmd/super/main.go:40 +0x5b
$ jq -c '.[]' ducks.json > ducks.ndjson &&
jq -c '.[]' samples.json > samples.ndjson &&
super -c "
SELECT ducks.firstName || ' ' || ducks.lastName AS duck_name,
samples.action,
COUNT(*) AS observations
FROM './samples.ndjson' AS samples
JOIN './ducks.ndjson' AS ducks ON ducks.id = samples.id
GROUP BY duck_name, samples.action
ORDER BY 1, 3 DESC;"
{duck_name:"Captain Quack",action:"sleeping",observations:890}
{duck_name:"Captain Quack",action:"quacking",observations:632}
...
Details
Repro is with super commit f597295.
The query above is from a blog post, adjusted to use named queries to deal with the JSON input data being in arrays. The problem seems specific to the use of named queries, as the panic is not triggered it if I turn the JSON into NDJSON in an external step.