compact_state_agg()
Aggregate state data into a state aggregate for further analysis
Early access 1.5.0
Aggregate a dataset containing state data into a state aggregate to track the time spent in each state.
Samples
Section titled “Samples”Create a state aggregate to track the status of some devices.
SELECT toolkit_experimental.compact_state_agg(time, status) FROM devices;Arguments
Section titled “Arguments”The syntax is:
compact_state_agg( ts TIMESTAMPTZ, value {TEXT | BIGINT}) RETURNS CompactStateAgg| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| ts | TIMESTAMPTZ | - | ✔ | Timestamps associated with each state reading |
| value | TEXT | BIGINT | - | ✔ |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| agg | CompactStateAgg | An object storing the total time spent in each state |