groupArrayResample
Description
The Resample
combinator can be applied to the groupArray
aggregate function to
divide the range of a specified key column into a fixed number of intervals (N
)
and construct the resulting array by selecting one representative value
(corresponding to the minimum key) from the data points falling into each interval.
It creates a downsampled view of the data rather than collecting all values.
Example Usage
Let's look at an example. We'll create a table which contains the name
, age
and
wage
of employees, and we'll insert some data into it:
Let's get the names of the people whose age lies in the intervals of [30,60)
and [60,75)
. Since we use integer representation for age, we get ages in the
[30, 59]
and [60,74]
intervals.
To aggregate names in an array, we use the groupArray
aggregate function.
It takes one argument. In our case, it's the name column. The groupArrayResample
function should use the age column to aggregate names by age. To define the
required intervals, we pass 30
, 75
, 30
as arguments into the groupArrayResample
function: