any
Aggregate Function
any — select an arbitrary input value
Synopsis
any(any) -> any
Description
The any aggregate function returns an arbitrary element from its input. The semantics of how the item is selected is not defined.
Examples
Any picks the first one in this scenario but this behavior is undefined:
echo '1 2 3 4' | zq -z 'any(this)' -
=>
1
Continuous any over a simple sequence:
echo '1 2 3 4' | zq -z 'yield any(this)' -
=>
1
1
1
1
Any is not sensitive to mixed types as it just picks one:
echo '"foo" 1 2 3 ' | zq -z 'any(this)' -
=>
"foo"
Pick from groups bucketed by key:
echo '{a:1,k:1} {a:2,k:1} {a:3,k:2} {a:4,k:2}' |
zq -z 'any(a) by k | sort' -
=>
{k:1,any:1}
{k:2,any:3}