brimdata / zed

A novel data lake based on super-structured data
https://zed.brimdata.io/
BSD 3-Clause "New" or "Revised" License
1.34k stars 67 forks source link

Anonymous/inline functions #5155

Open philrz opened 5 days ago

philrz commented 5 days ago

At the time this issue is being filed, Zed it at commit ab603fa.

I believe our own Dev team has at times wondered if Zed should offer anonymous functions. An outside user recently made their own inquiry in a community Slack thread.

is there a way to do an “inline” or => func with map? something like?

echo "$json" | zq -j 'map(this, =>(x) ({id:x.id * 2}))' -

Compare that with the working example I showed him that uses a named user-defined function.

$ echo "$json" | zq -z 'func times_two(x): ({id:x.id * 2}) yield map(this, times_two)' -
[{id:2},{id:4}]