From 8f4bc8da9421f9fe4178b09304611fabcf0f4ffb Mon Sep 17 00:00:00 2001 From: Phil Rzewski Date: Fri, 22 Sep 2023 11:05:00 -0700 Subject: [PATCH] Modify the cut/coalesce example in Zed language docs (#4776) --- docs/language/operators/cut.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/language/operators/cut.md b/docs/language/operators/cut.md index 2fee314001..6c26badbb5 100644 --- a/docs/language/operators/cut.md +++ b/docs/language/operators/cut.md @@ -74,8 +74,14 @@ 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)' - ``` @@ -83,4 +89,4 @@ 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} -``` \ No newline at end of file +```