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

Field copies don't preserve aliases #836

Closed henridf closed 4 years ago

henridf commented 4 years ago

When evaluating an expression over a field that has an aliased type, that alias is lost (during the roundtrip to the zngnative domain). A simple example here with just a field copy:

$ zq -t aliasin.tzng 
#ipaddr=ip
#0:record[host:ipaddr]
0:[127.0.0.1;]
17:30 ~/work/brim/zq(groupby-computed-keys)
$ zq -t "put host2=host" aliasin.tzng 
#ipaddr=ip
#0:record[host:ipaddr,host2:ip]
0:[127.0.0.1;127.0.0.1;]

Note that rather than consider this as a bug that should be directly fixed (such as somehow plumbing things to allow alias restoration upon re-entry from the zngnative world), we could also view it as an opportunity to step back and re-assess whether aliases are really needed in the zng (as opposed to a thin compatibility layer at the edges of zeekio).

(I ran into this issue while working on #535, where switching groupby keys to use expressions has broken a test on aliased key types).

henridf commented 4 years ago

We had a discussion where the conclusion was that this could be addressed as part of a broader re-working of expressions (other more or less closely related issues are #846 and #850 )

philrz commented 4 years ago

I can verify that this was fixed in zq commit 56ed80d that's associated with #1375. The alias is now preserved.

$ cat aliasin.tzng 
#ipaddr=ip
#0:record[host:ipaddr]
0:[127.0.0.1;]

$ zq -t "put host2=host" aliasin.tzng
#ipaddr=ip
#0:record[host:ipaddr,host2:ipaddr]
0:[127.0.0.1;127.0.0.1;]

Thanks @mccanne!