Skip to content

Commit

Permalink
Test non-adjacent rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
syvb committed Dec 6, 2022
1 parent 4024ca7 commit 8208b5d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/state_agg.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,23 @@ FROM buckets;
(OK,"2020-01-01 00:01:03+00","2020-01-01 00:02:00+00")
(STOP,"2020-01-01 00:02:00+00","2020-01-01 00:02:00+00")
```

```SQL
WITH buckets AS (SELECT
date_trunc('minute', ts) as dt,
toolkit_experimental.timeline_agg(ts, state) AS sa
FROM states_test
GROUP BY date_trunc('minute', ts)
HAVING date_trunc('minute', ts) != '2020-01-01 00:01:00+00'::timestamptz)
SELECT toolkit_experimental.state_timeline(
toolkit_experimental.rollup(buckets.sa)
)
FROM buckets;
```
```output
state_timeline
-----------------------------------------------------------
(START,"2020-01-01 00:00:00+00","2020-01-01 00:00:11+00")
(OK,"2020-01-01 00:00:11+00","2020-01-01 00:02:00+00")
(STOP,"2020-01-01 00:02:00+00","2020-01-01 00:02:00+00")
```

0 comments on commit 8208b5d

Please sign in to comment.