rollup()
Combine multiple state aggregates
Early access 1.13.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. The aggregates must not overlap: the last timestamp of each one
must be at or before the first timestamp of the next, and no two aggregates may start at the same timestamp.
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, toolkit_experimental.compact_state_agg(ts, state) AS saFROM states_testGROUP BY time_bucket('1 minute', ts))SELECT toolkit_experimental.duration_in( toolkit_experimental.rollup(buckets.sa), 'START')FROM buckets;Arguments
Section titled “Arguments”The syntax is:
rollup( value CompactStateAgg) RETURNS CompactStateAgg| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| value | CompactStateAgg | - | ✔ | State aggregates created using compact_state_agg |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| rollup | CompactStateAgg | A new state aggregate that combines the input state aggregates |