Skip to content

Commit

Permalink
docs: add cut with default value example
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Sep 19, 2023
1 parent aaf9752 commit fbb7880
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/language/operators/cut.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,13 @@ 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).
```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 fbb7880

Please sign in to comment.