From b6d853fe27e93aad5ae90ab1529ec8b885776326 Mon Sep 17 00:00:00 2001 From: Phil Rzewski Date: Wed, 28 Aug 2024 04:30:34 +0000 Subject: [PATCH] Break many docs examples across multiple lines (#5248) --- docs/commands/zq.md | 53 ++++++----- docs/language/aggregates/and.md | 3 +- docs/language/aggregates/any.md | 3 +- docs/language/aggregates/avg.md | 3 +- docs/language/aggregates/collect.md | 3 +- docs/language/aggregates/collect_map.md | 12 ++- docs/language/aggregates/fuse.md | 3 +- docs/language/aggregates/max.md | 3 +- docs/language/aggregates/min.md | 3 +- docs/language/aggregates/or.md | 3 +- docs/language/aggregates/sum.md | 3 +- docs/language/aggregates/union.md | 7 +- docs/language/data-types.md | 18 +++- docs/language/dataflow-model.md | 3 +- docs/language/expressions.md | 18 ++-- docs/language/functions/bucket.md | 3 +- docs/language/functions/cast.md | 7 +- docs/language/functions/cidr_match.md | 6 +- docs/language/functions/error.md | 6 +- docs/language/functions/every.md | 10 +- docs/language/functions/fields.md | 3 +- docs/language/functions/has.md | 3 +- docs/language/functions/is_error.md | 3 +- docs/language/functions/join.md | 3 +- docs/language/functions/ksuid.md | 3 +- docs/language/functions/len.md | 3 +- docs/language/functions/map.md | 11 ++- docs/language/functions/missing.md | 3 +- docs/language/functions/parse_uri.md | 3 +- docs/language/functions/parse_zson.md | 3 +- docs/language/functions/regexp.md | 3 +- docs/language/functions/regexp_replace.md | 17 +++- docs/language/functions/shape.md | 3 +- docs/language/functions/split.md | 3 +- docs/language/functions/typeof.md | 3 +- docs/language/functions/typeunder.md | 3 +- docs/language/functions/under.md | 7 +- docs/language/functions/unflatten.md | 11 ++- docs/language/functions/upper.md | 7 +- docs/language/lateral-subqueries.md | 14 ++- docs/language/operators/from.md | 18 +++- docs/language/operators/load.md | 25 ++++- docs/language/operators/over.md | 6 +- docs/language/operators/sample.md | 3 +- docs/language/operators/sort.md | 3 +- docs/language/operators/summarize.md | 9 +- docs/language/operators/switch.md | 18 +++- docs/language/operators/uniq.md | 3 +- docs/language/search-expressions.md | 6 +- docs/language/shaping.md | 29 ++++-- docs/language/statements.md | 10 +- docs/tutorials/schools.md | 110 ++++++++++++++++++---- docs/tutorials/zq.md | 87 ++++++++++++++--- 53 files changed, 449 insertions(+), 157 deletions(-) diff --git a/docs/commands/zq.md b/docs/commands/zq.md index 3ead0fb99a..13a45f6cd9 100644 --- a/docs/commands/zq.md +++ b/docs/commands/zq.md @@ -406,7 +406,8 @@ the previously-printed header line, a new header line will be output. For example: ```mdtest-command -echo '{word:"one",digit: 1} {word:"hello",style:"greeting"}' | zq -f table - +echo '{word:"one",digit: 1} {word:"hello",style:"greeting"}' | + zq -f table - ``` produces ```mdtest-output @@ -421,7 +422,8 @@ may prove useful to unify the input stream under a single record type that can be described with a single header line. Doing this to our last example, we find ```mdtest-command -echo '{word:"one",digit:1} {word:"hello",style:"greeting"}' | zq -f table 'fuse' - +echo '{word:"one",digit:1} {word:"hello",style:"greeting"}' | + zq -f table 'fuse' - ``` now produces ```mdtest-output @@ -517,22 +519,22 @@ alternative to the traditional technique of looking through logs for errors or trying to debug a halted program with a vague error message. For example, this query -``` -echo '1 2 0 3' | zq '10.0/this' - +```mdtest-command +echo '1 2 0 3' | zq -z '10.0/this' - ``` produces -``` +```mdtest-output 10. 5. error("divide by zero") 3.3333333333333335 ``` and -``` -echo '1 2 0 3' | zq '10.0/this' - | zq 'is_error(this)' - +```mdtest-command +echo '1 2 0 3' | zq '10.0/this' - | zq -z 'is_error(this)' - ``` produces just -``` +```mdtest-output error("divide by zero") ``` @@ -550,70 +552,71 @@ The language documentation and [tutorials directory](../tutorials/README.md) have many examples, but here are a few more simple `zq` use cases. _Hello, world_ -``` +```mdtest-command echo '"hello, world"' | zq -z 'yield this' - ``` produces this ZSON output -``` +```mdtest-output "hello, world" ``` _Some values of available [data types](../language/data-types.md)_ -``` +```mdtest-command echo '1 1.5 [1,"foo"] |["apple","banana"]|' | zq -z 'yield this' - ``` produces -``` +```mdtest-output 1 1.5 [1,"foo"] |["apple","banana"]| ``` _The types of various data_ -``` +```mdtest-command echo '1 1.5 [1,"foo"] |["apple","banana"]|' | zq -z 'yield typeof(this)' - ``` produces -``` +```mdtest-output <[(int64,string)]> <|[string]|> ``` _A simple [aggregation](../language/aggregates/README.md)_ -``` -echo '{key:"foo",val:1}{key:"bar",val:2}{key:"foo",val:3}' | zq -z 'sum(val) by key | sort key' - +```mdtest-command +echo '{key:"foo",val:1}{key:"bar",val:2}{key:"foo",val:3}' | + zq -z 'sum(val) by key | sort key' - ``` produces -``` +```mdtest-output {key:"bar",sum:2} {key:"foo",sum:4} ``` _Convert CSV to Zed and [cast](../language/functions/cast.md) a to an integer from default float_ -``` -printf "a,b\n1,foo\n2,bar\n" | zq 'a:=int64(a)' - +```mdtest-command +printf "a,b\n1,foo\n2,bar\n" | zq -z 'a:=int64(a)' - ``` produces -``` +```mdtest-output {a:1,b:"foo"} {a:2,b:"bar"} ``` _Convert JSON to Zed and cast to an integer from default float_ -``` -echo '{"a":1,"b":"foo"}{"a":2,"b":"bar"}' | zq 'a:=int64(a)' - +```mdtest-command +echo '{"a":1,"b":"foo"}{"a":2,"b":"bar"}' | zq -z 'a:=int64(a)' - ``` produces -``` +```mdtest-output {a:1,b:"foo"} {a:2,b:"bar"} ``` _Make a schema-rigid Parquet file using fuse and turn it back into Zed_ -``` +```mdtest-command echo '{a:1}{a:2}{b:3}' | zq -f parquet -o tmp.parquet fuse - zq -z tmp.parquet ``` produces -``` +```mdtest-output {a:1,b:null(int64)} {a:2,b:null(int64)} {a:null(int64),b:3} diff --git a/docs/language/aggregates/and.md b/docs/language/aggregates/and.md index 0c97631bce..aee5b5cd45 100644 --- a/docs/language/aggregates/and.md +++ b/docs/language/aggregates/and.md @@ -48,7 +48,8 @@ false AND of values grouped by key: ```mdtest-command -echo '{a:true,k:1} {a:true,k:1} {a:true,k:2} {a:false,k:2}' | zq -z 'and(a) by k | sort' - +echo '{a:true,k:1} {a:true,k:1} {a:true,k:2} {a:false,k:2}' | + zq -z 'and(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/any.md b/docs/language/aggregates/any.md index cf60795ee9..cbcd5dc2c0 100644 --- a/docs/language/aggregates/any.md +++ b/docs/language/aggregates/any.md @@ -46,7 +46,8 @@ echo '"foo" 1 2 3 ' | zq -z 'any(this)' - Pick from groups bucketed by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'any(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'any(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/avg.md b/docs/language/aggregates/avg.md index 7ba9045118..a2eba9db7f 100644 --- a/docs/language/aggregates/avg.md +++ b/docs/language/aggregates/avg.md @@ -45,7 +45,8 @@ echo '1 2 3 4 "foo"' | zq -z 'avg(this)' - Average of values bucketed by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'avg(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'avg(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/collect.md b/docs/language/aggregates/collect.md index 2b469b220a..8594d34157 100644 --- a/docs/language/aggregates/collect.md +++ b/docs/language/aggregates/collect.md @@ -47,7 +47,8 @@ echo '1 2 3 4 "foo"' | zq -z 'collect(this)' - Create arrays of values bucketed by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'collect(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'collect(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/collect_map.md b/docs/language/aggregates/collect_map.md index ae9c47ab33..270c5a8daf 100644 --- a/docs/language/aggregates/collect_map.md +++ b/docs/language/aggregates/collect_map.md @@ -18,7 +18,8 @@ of union of those types. Combine a sequence of records into a map: ```mdtest-command -echo '{stock:"APPL",price:145.03} {stock:"GOOG",price:87.07}' | zq -z 'collect_map(|{stock:price}|)' - +echo '{stock:"APPL",price:145.03} {stock:"GOOG",price:87.07}' | + zq -z 'collect_map(|{stock:price}|)' - ``` => ```mdtest-output @@ -27,7 +28,8 @@ echo '{stock:"APPL",price:145.03} {stock:"GOOG",price:87.07}' | zq -z 'collect_m Continuous collection over a simple sequence: ```mdtest-command -echo '|{"APPL":145.03}| |{"GOOG":87.07}| |{"APPL":150.13}|' | zq -z 'yield collect_map(this)' - +echo '|{"APPL":145.03}| |{"GOOG":87.07}| |{"APPL":150.13}|' | + zq -z 'yield collect_map(this)' - ``` => ```mdtest-output @@ -38,7 +40,11 @@ echo '|{"APPL":145.03}| |{"GOOG":87.07}| |{"APPL":150.13}|' | zq -z 'yield colle Create maps by key: ```mdtest-command -echo '{stock:"APPL",price:145.03,day:0} {stock:"GOOG",price:87.07,day:0} {stock:"APPL",price:150.13,day:1} {stock:"GOOG",price:89.15,day:1}' | zq -z 'collect_map(|{stock:price}|) by day | sort' - +echo '{stock:"APPL",price:145.03,day:0} + {stock:"GOOG",price:87.07,day:0} + {stock:"APPL",price:150.13,day:1} + {stock:"GOOG",price:89.15,day:1}' | + zq -z 'collect_map(|{stock:price}|) by day | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/fuse.md b/docs/language/aggregates/fuse.md index c3a28a6e01..78e6a31a72 100644 --- a/docs/language/aggregates/fuse.md +++ b/docs/language/aggregates/fuse.md @@ -28,7 +28,8 @@ echo '{a:1,b:2}{a:2,b:"foo"}' | zq -z 'fuse(this)' - ``` Fuse records with a group-by key: ```mdtest-command -echo '{a:1,b:"bar"}{a:2.1,b:"foo"}{a:3,b:"bar"}' | zq -z 'fuse(this) by b | sort' - +echo '{a:1,b:"bar"}{a:2.1,b:"foo"}{a:3,b:"bar"}' | + zq -z 'fuse(this) by b | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/max.md b/docs/language/aggregates/max.md index c4268ea867..032bfaad6c 100644 --- a/docs/language/aggregates/max.md +++ b/docs/language/aggregates/max.md @@ -45,7 +45,8 @@ echo '1 2 3 4 "foo"' | zq -z 'max(this)' - Maximum value within buckets grouped by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'max(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'max(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/min.md b/docs/language/aggregates/min.md index 3ef7efd9d6..99c889fc2b 100644 --- a/docs/language/aggregates/min.md +++ b/docs/language/aggregates/min.md @@ -45,7 +45,8 @@ echo '1 2 3 4 "foo"' | zq -z 'min(this)' - Minimum value within buckets grouped by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'min(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'min(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/or.md b/docs/language/aggregates/or.md index 9949078b82..8667d636b5 100644 --- a/docs/language/aggregates/or.md +++ b/docs/language/aggregates/or.md @@ -48,7 +48,8 @@ true OR of values grouped by key: ```mdtest-command -echo '{a:true,k:1} {a:false,k:1} {a:false,k:2} {a:false,k:2}' | zq -z 'or(a) by k | sort' - +echo '{a:true,k:1} {a:false,k:1} {a:false,k:2} {a:false,k:2}' | + zq -z 'or(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/sum.md b/docs/language/aggregates/sum.md index aec5ebb1bd..120a407f76 100644 --- a/docs/language/aggregates/sum.md +++ b/docs/language/aggregates/sum.md @@ -45,7 +45,8 @@ echo '1 2 3 4 "foo"' | zq -z 'sum(this)' - Sum of values bucketed by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'sum(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'sum(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/aggregates/union.md b/docs/language/aggregates/union.md index ff37405c3f..d3db7f140d 100644 --- a/docs/language/aggregates/union.md +++ b/docs/language/aggregates/union.md @@ -38,18 +38,19 @@ echo '1 2 3 3' | zq -z 'yield union(this)' - ``` Mixed types create a union type for the set elements: -```mdtest-command-issue-3610 +```mdtest-command echo '1 2 3 "foo"' | zq -z 'set:=union(this) | yield this,typeof(set)' - ``` => -```mdtest-output-issue-3610 +```mdtest-output {set:|[1,2,3,"foo"]|} <|[(int64,string)]|> ``` Create sets of values bucketed by key: ```mdtest-command -echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | zq -z 'union(a) by k | sort' - +echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' | + zq -z 'union(a) by k | sort' - ``` => ```mdtest-output diff --git a/docs/language/data-types.md b/docs/language/data-types.md index fc7b0111cd..06da67a7c1 100644 --- a/docs/language/data-types.md +++ b/docs/language/data-types.md @@ -58,7 +58,8 @@ search ... | count() by typeof(this) ``` For example, ```mdtest-command -echo '1 2 "foo" 10.0.0.1 ' | zq -z 'count() by typeof(this) | sort this' - +echo '1 2 "foo" 10.0.0.1 ' | + zq -z 'count() by typeof(this) | sort this' - ``` produces ```mdtest-output @@ -142,7 +143,8 @@ Each value that references a named type retains its local definition of the named type retaining the proper type binding while accommodating changes in a particular named type. For example, ```mdtest-command -echo '1(=foo) 2(=bar) "hello"(=foo) 3(=foo)' | zq -z 'count() by typeof(this) | sort this' - +echo '1(=foo) 2(=bar) "hello"(=foo) 3(=foo)' | + zq -z 'count() by typeof(this) | sort this' - ``` results in ```mdtest-output @@ -176,12 +178,20 @@ LIMIT 5 ``` In Zed, you would say ``` -from anywhere | typeof(this)== | cut last,salary | sort salary | head 5 +from anywhere +| typeof(this)== +| cut last,salary +| sort salary +| head 5 ``` and since type comparisons are so useful and common, the [`is` function](functions/is.md) can be used to perform the type match: ``` -from anywhere | is() | cut last,salary | sort salary | head 5 +from anywhere +| is() +| cut last,salary +| sort salary +| head 5 ``` The power of Zed is that you can interpret data on the fly as belonging to a certain schema, in this case "employee", and those records can be intermixed diff --git a/docs/language/dataflow-model.md b/docs/language/dataflow-model.md index 92144a0a44..abb8d884bc 100644 --- a/docs/language/dataflow-model.md +++ b/docs/language/dataflow-model.md @@ -25,7 +25,8 @@ but as an example, you might use the `get` form of `from` to fetch data from an HTTP endpoint and process it with Zed, in this case, to extract the description and license of a GitHub repository: ``` -zq -f text "get https://api.github.com/repos/brimdata/zed | yield description,license.name" +zq -f text 'get https://api.github.com/repos/brimdata/zed + | yield description,license.name' ``` When a Zed query is run on the command-line with `zq`, the `from` source is typically omitted and implied instead by the command-line file arguments. diff --git a/docs/language/expressions.md b/docs/language/expressions.md index 70a1b09b4c..5a4369e1bd 100644 --- a/docs/language/expressions.md +++ b/docs/language/expressions.md @@ -80,7 +80,8 @@ produces ``` You can also use this operator with a static array: ```mdtest-command -echo '{accounts:[{id:1},{id:2},{id:3}]}' | zq -z 'over accounts | where id in [1,2]' - +echo '{accounts:[{id:1},{id:2},{id:3}]}' | + zq -z 'over accounts | where id in [1,2]' - ``` produces ```mdtest-output @@ -200,7 +201,8 @@ will be evaluated. For example, ```mdtest-command -echo '"foo" "bar" "foo"' | zq -z 'yield this=="foo" ? {foocount:count()} : {barcount:count()}' - +echo '"foo" "bar" "foo"' | + zq -z 'yield this=="foo" ? {foocount:count()} : {barcount:count()}' - ``` produces ```mdtest-output @@ -283,7 +285,8 @@ a string, it is implicitly cast to a string. For example, ```mdtest-command -echo '{numerator:22.0, denominator:7.0}' | zq -z 'yield f"pi is approximately {numerator / denominator}"' - +echo '{numerator:22.0, denominator:7.0}' | + zq -z 'yield f"pi is approximately {numerator / denominator}"' - ``` produces ```mdtest-output @@ -301,7 +304,8 @@ F-strings may be nested, where a child `` may contain f-strings. For example, ```mdtest-command -echo '{foo:"hello", bar:"world", HELLOWORLD:"hi!"}' | zq -z 'yield f"oh {this[upper(f"{foo + bar}")]}"' - +echo '{foo:"hello", bar:"world", HELLOWORLD:"hi!"}' | + zq -z 'yield f"oh {this[upper(f"{foo + bar}")]}"' - ``` produces ```mdtest-output @@ -347,7 +351,8 @@ field's value. For example, ```mdtest-command -echo '{x:1,y:2,r:{a:1,b:2}}' | zq -z 'yield {a:0},{x}, {...r}, {a:0,...r,b:3}' - +echo '{x:1,y:2,r:{a:1,b:2}}' | + zq -z 'yield {a:0},{x}, {...r}, {a:0,...r,b:3}' - ``` produces ```mdtest-output @@ -563,7 +568,8 @@ produces ``` and ```mdtest-command -echo '{ts:"1/1/2022",r:{x:"1",y:"2"}} {ts:"1/2/2022",r:{x:3,y:4}}' | zq -z 'cast(this,<{ts:time,r:{x:float64,y:float64}}>)' - +echo '{ts:"1/1/2022",r:{x:"1",y:"2"}} {ts:"1/2/2022",r:{x:3,y:4}}' | + zq -z 'cast(this,<{ts:time,r:{x:float64,y:float64}}>)' - ``` produces ```mdtest-output diff --git a/docs/language/functions/bucket.md b/docs/language/functions/bucket.md index 295bf4c382..9d8f27942c 100644 --- a/docs/language/functions/bucket.md +++ b/docs/language/functions/bucket.md @@ -20,7 +20,8 @@ aligns with 0. Bucket a couple times to hour intervals: ```mdtest-command -echo '2020-05-26T15:27:47Z "5/26/2020 3:27pm"' | zq -z 'yield bucket(time(this), 1h)' - +echo '2020-05-26T15:27:47Z "5/26/2020 3:27pm"' | + zq -z 'yield bucket(time(this), 1h)' - ``` => ```mdtest-output diff --git a/docs/language/functions/cast.md b/docs/language/functions/cast.md index 11184470bf..f1a476fb53 100644 --- a/docs/language/functions/cast.md +++ b/docs/language/functions/cast.md @@ -83,7 +83,12 @@ produces _Name data based its properties_ ```mdtest-command -echo '{x:1,y:2}{r:3}{x:4,y:5}' | zq -z 'switch ( case has(x) => cast(this, "point") default => cast(this, "radius") ) | sort this' - +echo '{x:1,y:2}{r:3}{x:4,y:5}' | + zq -z 'switch ( + case has(x) => cast(this, "point") + default => cast(this, "radius") + ) + | sort this' - ``` produces ```mdtest-output diff --git a/docs/language/functions/cidr_match.md b/docs/language/functions/cidr_match.md index dcbcb71b35..d28e32494e 100644 --- a/docs/language/functions/cidr_match.md +++ b/docs/language/functions/cidr_match.md @@ -19,7 +19,8 @@ If `network` is not type `net`, then an error is returned. Test whether values are IP addresses in a network: ```mdtest-command -echo '10.1.2.129 11.1.2.129 10 "foo"' | zq -z 'yield cidr_match(10.0.0.0/8, this)' - +echo '10.1.2.129 11.1.2.129 10 "foo"' | + zq -z 'yield cidr_match(10.0.0.0/8, this)' - ``` => ```mdtest-output @@ -31,7 +32,8 @@ false It also works for IPs in complex values: ```mdtest-command -echo '[10.1.2.129,11.1.2.129] {a:10.0.0.1} {a:11.0.0.1}' | zq -z 'yield cidr_match(10.0.0.0/8, this)' - +echo '[10.1.2.129,11.1.2.129] {a:10.0.0.1} {a:11.0.0.1}' | + zq -z 'yield cidr_match(10.0.0.0/8, this)' - ``` => ```mdtest-output diff --git a/docs/language/functions/error.md b/docs/language/functions/error.md index 988eb7f4d5..d1c48bf854 100644 --- a/docs/language/functions/error.md +++ b/docs/language/functions/error.md @@ -18,7 +18,8 @@ a means to create structured and stacked errors. Wrap a record as a structured error: ```mdtest-command -echo '{foo:"foo"}' | zq -z 'yield error({message:"bad value", value:this})' - +echo '{foo:"foo"}' | + zq -z 'yield error({message:"bad value", value:this})' - ``` => ```mdtest-output @@ -38,7 +39,8 @@ error([1,2,3]) Test if a value is an error and show its type "kind": ```mdtest-command -echo 'error("exception") "exception"' | zq -Z 'yield {this,err:is_error(this),kind:kind(this)}' - +echo 'error("exception") "exception"' | + zq -Z 'yield {this,err:is_error(this),kind:kind(this)}' - ``` => ```mdtest-output diff --git a/docs/language/functions/every.md b/docs/language/functions/every.md index 37f6af05d8..540996018e 100644 --- a/docs/language/functions/every.md +++ b/docs/language/functions/every.md @@ -18,7 +18,10 @@ when analyzing time-series data like logs that have a `ts` field. Operate on a sequence of times: ```mdtest-command -echo '{ts:2021-02-01T12:00:01Z}' | zq -z 'yield {ts,val:0},{ts:ts+1s},{ts:ts+2h2s} | yield every(1h) | sort' - +echo '{ts:2021-02-01T12:00:01Z}' | + zq -z 'yield {ts,val:0},{ts:ts+1s},{ts:ts+2h2s} + | yield every(1h) + | sort' - ``` -> ```mdtest-output @@ -28,7 +31,10 @@ echo '{ts:2021-02-01T12:00:01Z}' | zq -z 'yield {ts,val:0},{ts:ts+1s},{ts:ts+2h2 ``` Use as a group-by key: ```mdtest-command -echo '{ts:2021-02-01T12:00:01Z}' | zq -z 'yield {ts,val:1},{ts:ts+1s,val:2},{ts:ts+2h2s,val:5} | sum(val) by every(1h) | sort' - +echo '{ts:2021-02-01T12:00:01Z}' | + zq -z 'yield {ts,val:1},{ts:ts+1s,val:2},{ts:ts+2h2s,val:5} + | sum(val) by every(1h) + | sort' - ``` -> ```mdtest-output diff --git a/docs/language/functions/fields.md b/docs/language/functions/fields.md index 7811887ac8..47051dde6b 100644 --- a/docs/language/functions/fields.md +++ b/docs/language/functions/fields.md @@ -29,7 +29,8 @@ echo '{a:1,b:2,c:{d:3,e:4}}' | zq -z 'yield fields(this)' - ``` Easily convert to dotted names if you prefer: ```mdtest-command -echo '{a:1,b:2,c:{d:3,e:4}}' | zq -z 'over fields(this) | yield join(this,".")' - +echo '{a:1,b:2,c:{d:3,e:4}}' | + zq -z 'over fields(this) | yield join(this,".")' - ``` => ```mdtest-output diff --git a/docs/language/functions/has.md b/docs/language/functions/has.md index d1ddefc03d..ef6561e9b9 100644 --- a/docs/language/functions/has.md +++ b/docs/language/functions/has.md @@ -33,7 +33,8 @@ switch ( ```mdtest-command echo '{foo:10}' | zq -z 'yield {yes:has(foo),no:has(bar)}' - echo '{foo:[1,2,3]}' | zq -z 'yield {yes: has(foo[0]),no:has(foo[3])}' - -echo '{foo:{bar:"value"}}' | zq -z 'yield {yes:has(foo.bar),no:has(foo.baz)}' - +echo '{foo:{bar:"value"}}' | + zq -z 'yield {yes:has(foo.bar),no:has(foo.baz)}' - echo '{foo:10}' | zq -z 'yield {yes:has(foo+1),no:has(bar+1)}' - echo 1 | zq -z 'yield has(bar)' - echo '{x:error("missing")}' | zq -z 'yield has(x)' - diff --git a/docs/language/functions/is_error.md b/docs/language/functions/is_error.md index 3d2801b2f0..2905eaaaa5 100644 --- a/docs/language/functions/is_error.md +++ b/docs/language/functions/is_error.md @@ -35,7 +35,8 @@ true Convert an error string into a record with an indicator and a message: ```mdtest-command -echo '"not an error" error("an error")' | zq -z 'yield {err:is_error(this),message:under(this)}' - +echo '"not an error" error("an error")' | + zq -z 'yield {err:is_error(this),message:under(this)}' - ``` => ```mdtest-output diff --git a/docs/language/functions/join.md b/docs/language/functions/join.md index 78f44501aa..2f99f65727 100644 --- a/docs/language/functions/join.md +++ b/docs/language/functions/join.md @@ -26,7 +26,8 @@ echo '["a","b","c"]' | zq -z 'yield join(this, ",")' - Join non-string arrays by first casting: ```mdtest-command -echo '[1,2,3] [10.0.0.1,10.0.0.2]' | zq -z 'yield join(cast(this, <[string]>), "...")' - +echo '[1,2,3] [10.0.0.1,10.0.0.2]' | + zq -z 'yield join(cast(this, <[string]>), "...")' - ``` => ```mdtest-output diff --git a/docs/language/functions/ksuid.md b/docs/language/functions/ksuid.md index d225c6a0ce..1b06989b32 100644 --- a/docs/language/functions/ksuid.md +++ b/docs/language/functions/ksuid.md @@ -22,7 +22,8 @@ returned as a bytes value. #### Example: ```mdtest-command -echo '{id:0x0dfc90519b60f362e84a3fdddd9b9e63e1fb90d1}' | zq -z 'id := ksuid(id)' - +echo '{id:0x0dfc90519b60f362e84a3fdddd9b9e63e1fb90d1}' | + zq -z 'id := ksuid(id)' - ``` => ```mdtest-output diff --git a/docs/language/functions/len.md b/docs/language/functions/len.md index ce7e320c51..1a3ffa4972 100644 --- a/docs/language/functions/len.md +++ b/docs/language/functions/len.md @@ -30,7 +30,8 @@ Supported types include: Take the length of various types: ```mdtest-command -echo '[1,2,3] |["hello"]| {a:1,b:2} "hello" 10.0.0.1 1' | zq -z 'yield {this,len:len(this)}' - +echo '[1,2,3] |["hello"]| {a:1,b:2} "hello" 10.0.0.1 1' | + zq -z 'yield {this,len:len(this)}' - ``` => ```mdtest-output diff --git a/docs/language/functions/map.md b/docs/language/functions/map.md index 39b2f5b8a7..03b120a654 100644 --- a/docs/language/functions/map.md +++ b/docs/language/functions/map.md @@ -29,10 +29,13 @@ echo '["foo","bar","baz"]' | zq -z 'yield map(this, upper)' - Using a user-defined function to convert an epoch float to a time: ```mdtest-command -echo '[1697151533.41415,1697151540.716529]' | zq -z ' - func floatToTime(x): ( cast(x*1000000000,