Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

# spq
any(this)
# input
1
2
3
4
# expected output
1

Any is not sensitive to mixed types as it just picks one:

# spq
any(this)
# input
"foo"
1
2
3
# expected output
"foo"

Pick from groups bucketed by key:

# spq
any(a) by k | sort
# input
{a:1,k:1}
{a:2,k:1}
{a:3,k:2}
{a:4,k:2}
# expected output
{k:1,any:1}
{k:2,any:3}