From 7b67ce1866b3fe101df9f5f3f73694d0fc6891e5 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Thu, 21 Sep 2023 15:38:44 -0600 Subject: [PATCH] docs: cut with default value (#4773) --- docs/language/operators/cut.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/language/operators/cut.md b/docs/language/operators/cut.md index d288ef4c1a..2fee314001 100644 --- a/docs/language/operators/cut.md +++ b/docs/language/operators/cut.md @@ -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} +``` \ No newline at end of file