Closed philrz closed 3 months ago
Verified in Zed commit aca5032.
Both of the repro cases above now return the expected type name rather than error("missing")
as it had before.
$ zq -version
Version: v1.14.0-25-gaca50328
$ echo '80(port=int16)' | zq -z 'yield nameof(<port>)' -
"port"
$ echo {} | zq -I shaper.zed '| yield nameof(typeof(this))' -
"dns"
Thanks @mattnibs!
tl;dr
The following should return
"port"
.Details
Repro is with Zed commit 38763f8.
A community user recently inquired in a Slack thread:
Based on the screenshot, it appears the user is following the Zed docs for shaping Zeek NDJSON. Starting from here, there's a couple ways to get the Zeek record type from the record values, e.g.,
yield _path
(since with Zeek data the_path
field happens to map 1-to-1 with the record types), ornameof(this)
, such as in this simplified example based on the Zeek shaping docs:However, if we start from the user's position of wanting to derive this info from the
type
value that returrned from thetypeof
function, that's not currently possible vianameof
.We discussed this one as a group and there was consensus that it would be good to add support for this. In the meantime, in addition to the workarounds shown above that derive the type name from the original value, I also offered the user this hacky workaround that extracts the name from the string representation of the record type definition.