rollup()
Combines multiple StateAgg/TimelineAgg aggregates. Using rollup, you can reaggregate a continuous aggregate into larger time buckets.
2. rollup(
4. agg [StateAgg | TimelineAgg]
6. ) RETURNS [StateAgg | TimelineAgg]
warning
Experimental features could have bugs. They might not be backwards compatible, and could be removed in future releases. Use these features at your own risk, and do not use any experimental features in production.
Required arguments
| Name | Type | Description |
|---|---|---|
agg |
StateAgg or TimelineAgg |
The aggregates to roll up |
Returns
| Column | Type | Description |
|---|---|---|
agg |
StateAgg or TimelineAgg |
A new aggregate containing the combined rolled-up aggregates. |
Sample usage
2. WITH buckets AS (SELECT
4. time_bucket('1 minute', ts) as dt,
6. toolkit_experimental.state_agg(ts, state) AS sa
8. FROM states_test
10. GROUP BY time_bucket('1 minute', ts))
12. SELECT toolkit_experimental.duration_in(
14. 'START',
16. toolkit_experimental.rollup(buckets.sa)
18. )
20. FROM buckets;
