Skip to content

Commit

Permalink
Use Zed sort in docs/language/operators/summarize.md (#5323)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwt authored Oct 7, 2024
1 parent b0853e6 commit b05e70b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/language/operators/summarize.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ echo '1 2 3 4' | zq -z 'sum(this)' -
Create integer sets by key and sort the output to get a deterministic order:
```mdtest-command
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'set:=union(v) by key:=k' - | sort
zq -z 'set:=union(v) by key:=k | sort' -
```
=>
```mdtest-output
Expand All @@ -105,7 +105,7 @@ echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
Use a `where` clause:
```mdtest-command
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'set:=union(v) where v > 1 by key:=k' - | sort
zq -z 'set:=union(v) where v > 1 by key:=k | sort' -
```
=>
```mdtest-output
Expand All @@ -119,7 +119,7 @@ Use separate `where` clauses on each aggregate function:
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'set:=union(v) where v > 1,
array:=collect(v) where k=="foo"
by key:=k' - | sort
by key:=k | sort' -
```
=>
```mdtest-output
Expand All @@ -132,7 +132,7 @@ Results are included for `by` groupings that generate null results when `where`
clauses are used inside `summarize`:
```mdtest-command
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'sum(v) where k=="bar" by key:=k' - | sort
zq -z 'sum(v) where k=="bar" by key:=k | sort' -
```
=>
```mdtest-output
Expand All @@ -144,7 +144,7 @@ echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
To avoid null results for `by` groupings a just shown, filter before `summarize`:
```mdtest-command
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'k=="bar" | sum(v) by key:=k' - | sort
zq -z 'k=="bar" | sum(v) by key:=k | sort' -
```
=>
```mdtest-output
Expand All @@ -154,7 +154,7 @@ echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
Output just the unique key values:
```mdtest-command
echo '{k:"foo",v:1}{k:"bar",v:2}{k:"foo",v:3}{k:"baz",v:4}' |
zq -z 'by k' - | sort
zq -z 'by k | sort' -
```
=>
```mdtest-output
Expand Down

0 comments on commit b05e70b

Please sign in to comment.