state_timeline()
Returns the timeline of states in a timeline aggregate.
state_timeline(
agg TimelineAgg
) RETURNS (TEXT, TIMESTAMPTZ, TIMESTAMPTZ)
state_int_timeline(
agg TimelineAgg
) RETURNS (BIGINT, TIMESTAMPTZ, TIMESTAMPTZ)
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 | TimelineAgg | The aggregate to get data for |
Returns
Column | Type | Description |
---|---|---|
state | TEXT or BIGINT | A state found in the TimelineAgg |
start_time | TIMESTAMPTZ | The time the state started at (inclusive) |
end_time | TIMESTAMPTZ | The time the state ended at (exclusive) |
Sample usage
Getting the history of states in a timeline aggregate:
SELECT state, start_time, end_time FROM toolkit_experimental.state_timeline(
(SELECT toolkit_experimental.timeline_agg(ts, state) FROM states_test));
Example output:
state | start_time | end_time
-------+------------------------+------------------------
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:01:00+00
ERROR | 2020-01-01 00:01:00+00 | 2020-01-01 00:01:03+00
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
当前内容版权归 TimescaleDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 TimescaleDB .