Skip to content

Commit

Permalink
Add a uniq docs example showing record values (#5271)
Browse files Browse the repository at this point in the history
  • Loading branch information
philrz authored Sep 14, 2024
1 parent 4290afd commit 2320f79
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/language/operators/uniq.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ echo '1 2 2 3' | zq -z 'uniq -c' -
{value:2,count:2(uint64)}
{value:3,count:1(uint64)}
```

_Use sort to deduplicate non-adjacent values_
```mdtest-command
echo '"hello" "world" "goodbye" "world" "hello" "again"' |
Expand All @@ -56,3 +57,20 @@ echo '"hello" "world" "goodbye" "world" "hello" "again"' |
"hello"
"world"
```

_Complex values must match fully to be considered duplicate (e.g., every field/value pair in adjacent records)_
```mdtest-command
echo '{ts:2024-09-10T21:12:33Z, action:"start"}
{ts:2024-09-10T21:12:34Z, action:"running"}
{ts:2024-09-10T21:12:34Z, action:"running"}
{ts:2024-09-10T21:12:35Z, action:"running"}
{ts:2024-09-10T21:12:36Z, action:"stop"}' |
zq -z 'uniq' -
```
=>
```mdtest-output
{ts:2024-09-10T21:12:33Z,action:"start"}
{ts:2024-09-10T21:12:34Z,action:"running"}
{ts:2024-09-10T21:12:35Z,action:"running"}
{ts:2024-09-10T21:12:36Z,action:"stop"}
```

0 comments on commit 2320f79

Please sign in to comment.