Skip to content

Commit

Permalink
Modify the cut/coalesce example in Zed language docs (#4776)
Browse files Browse the repository at this point in the history
  • Loading branch information
philrz authored Sep 22, 2023
1 parent 7b67ce1 commit 8f4bc8d
Showing 1 changed file with 9 additions and 3 deletions.
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}
```
```

0 comments on commit 8f4bc8d

Please sign in to comment.