Skip to content
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

Modify the cut/coalesce example in Zed language docs #4776

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/language/operators/cut.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ echo '1 {a:1,b:2,c:3}' | zq -z 'cut a,b' -
{a:error("missing"),b:error("missing")}
{a:1,b:2}
```
_Set default values for fields with null values_
This can be helpful when using the `csv` export format, which expects a uniform record structure (which includes field types).
_Invoke a function while cutting to set a default value for a field_

:::tip
This can be helpful to transform data into a uniform record type, such as if
the output will be exported in formats such as `csv` or `parquet` (see also:
[`fuse`](fuse.md)).
:::

```mdtest-command
echo '{a:1,b:null}{a:1,b:2}' | zq -z 'cut a,b:=coalesce(b, 0)' -
```
=>
```mdtest-output
{a:1,b:0}
{a:1,b:2}
```
```