rollup()
Combine multiple state aggregates
Since 1.15.0
Combine multiple state aggregates into a single state aggregate. For example, you can use rollup to combine state
aggregates from 15-minute buckets into daily buckets.
Samples
Section titled “Samples”Combine multiple state aggregates and calculate the duration spent in the START state.
WITH buckets AS (SELECT time_bucket('1 minute', ts) as dt, state_agg(ts, state) AS saFROM states_testGROUP BY time_bucket('1 minute', ts))SELECT duration_in( 'START', rollup(buckets.sa))FROM buckets;Arguments
Section titled “Arguments”The syntax is:
rollup( agg StateAgg) RETURNS StateAgg| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| agg | StateAgg | - | ✔ | State aggregates created using state_agg |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| agg | StateAgg | A new state aggregate that combines the input state aggregates |