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

Alias handling bug in zjson writer #758

Closed henridf closed 4 years ago

henridf commented 4 years ago

The zjson writer handles aliases to primitive types ok, but not aliases to container types. (The zjson reader likely has a similar issue).

$ cat alias.tzng 
#0:record[host:ip]
0:[127.0.0.2;]
#myrec=record[host:ip]
#1:record[foo:myrec]
1:[[127.0.0.2;]]
19:21 ~/work/brim/zq(zeekstrings-to-zeekio)
$ zq -f zjson alias.tzng 
{"id":23,"type":[{"name":"host","type":"ip"}],"values":["127.0.0.2"]}
malformed zng value
philrz commented 4 years ago

Verified in zq commit a14daef. The original repro now generate output rather than an error.

$ zq -f zjson alias.tzng
{"id":23,"type":[{"name":"host","type":"ip"}],"values":["127.0.0.2"]}
{"id":25,"type":[{"name":"foo","type":"myrec"}],"aliases":[{"name":"myrec","type":"record[host:ip]"}],"values":[["127.0.0.2"]]}

Thanks @henridf!