-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zed shorthand to create a record field name from string #4555
Comments
@mccanne recently had the following reactions.
|
Verified in Zed commit 92b0acd. The syntax shown as the middle of the three queries I tried above that previously failed now works as expected, no longer returning the
Thanks @mattnibs! |
At the time of the filing of this issue, Zed is at commit 1874aeb.
The attached scan.json.gz is a trimmed masscan report of the kind referenced in this tweet. The
jq
example shown there formats it thusly:The cleanest Zed I thought of that outputs something close to that is:
However, notice in this case that we've got named fields
ip
andports
whereas in thejq
example the IP address string was used as an object key with the value being the array of port data. If a user wanted to get the exact same outputjq
was producing, the best approach the team came up with is:(There's actually a subtle difference between this output and what came from
jq
, but that's further explored in #4565.)This idiom of
collect()
+unflatten()
has come up a few times before (example: #4332) and I'm starting to see why:unflatten([{key:...,value:...}])
is the only way I can see to create new field/value pairs in records where the field name is based on a string that's been programmatically generated within the Zed pipeline. It therefore seems like we could benefit from some shorthand that would achieve the same. I'm at a loss for what precisely to propose, but I sense it would be something like the indexing syntax but usable on in "left hand" contexts. For instance, when hacking at this, things I tried in vain hoping they might work included:The text was updated successfully, but these errors were encountered: