union
Aggregate Function
union — set union of input values
Synopsis
union(any) -> |[any]|
Description
The union aggregate function computes a set union of its input values. If the values are of uniform type, then the output is a set of that type. If the values are of mixed typs, the the output is a set of union of the types encountered.
Examples
Create a set of values from a simple sequence:
union(this)
1
2
3
3
Loading...
echo '1
2
3
3' \
| super -z -c 'union(this)' -
Create sets continuously from values in a simple sequence:
yield union(this)
1
2
3
3
Loading...
echo '1
2
3
3' \
| super -z -c 'yield union(this)' -
Mixed types create a union type for the set elements:
set:=union(this) | yield this,typeof(set)
1
2
3
"foo"
Loading...
echo '1
2
3
"foo"' \
| super -z -c 'set:=union(this) | yield this,typeof(set)' -
Create sets of values bucketed by key:
union(a) by k | sort
{a:1,k:1}
{a:2,k:1}
{a:3,k:2}
{a:4,k:2}
Loading...
echo '{a:1,k:1}
{a:2,k:1}
{a:3,k:2}
{a:4,k:2}' \
| super -z -c 'union(a) by k | sort' -