From 444896801629296e931a48569403365f9df5fb10 Mon Sep 17 00:00:00 2001 From: Phil Rzewski Date: Thu, 21 Sep 2023 16:03:47 -0700 Subject: [PATCH] Modify the cut/coalesce example in Zed language docs --- docs/language/operators/cut.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/language/operators/cut.md b/docs/language/operators/cut.md index d288ef4c1a..6c26badbb5 100644 --- a/docs/language/operators/cut.md +++ b/docs/language/operators/cut.md @@ -74,3 +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} ``` +_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} +```