Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ This changelog should be updated as part of a PR if the work is worth noting (mo
#### Bug fixes
- [#715](https://github.com/timescale/timescaledb-toolkit/pull/715): Fix out-of-bounds indexing error in `state_agg` rollup

#### Stabilized features
- [#722](https://github.com/timescale/timescaledb-toolkit/pull/722): Stabilize heartbeat aggregate.

#### Other notable changes
- [#716](https://github.com/timescale/timescaledb-toolkit/issues/716): Add arrow operator support for counter aggregate and time-weighted aggregate interpolated accessors.
- [#716](https://github.com/timescale/timescaledb-toolkit/issues/716): Remove experimental versions of interpolated accessors for counter aggregate and time-weighted aggregates. The stable versions introduced in 1.14.0 should be used instead.
Expand Down
22 changes: 21 additions & 1 deletion docs/test_caggs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AS SELECT
hyperloglog(64, value1) as hll,
counter_agg(time, value1) as counter,
stats_agg(value1, value2) as stats,
timevector(time, value2) as tvec
timevector(time, value2) as tvec,
heartbeat_agg(time, time_bucket('7 day'::interval, time), '1w', '55m') as hb
FROM test
GROUP BY time_bucket('7 day'::interval, time);
```
Expand Down Expand Up @@ -114,3 +115,22 @@ ORDER BY week;
2020-07-20 00:00:00+00 | 168
2020-07-27 00:00:00+00 | 59
```

```SQL
SELECT week, uptime(hb), interpolated_uptime(hb, LAG(hb) OVER (ORDER BY week))
FROM weekly_aggs
WHERE week > '2020-06-01'
ORDER BY week;
```
```output
week | uptime | interpolated_uptime
------------------------+-----------------+---------------------
2020-06-08 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-06-15 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-06-22 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-06-29 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-07-06 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-07-13 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-07-20 00:00:00+00 | 6 days 10:00:00 | 6 days 10:00:00
2020-07-27 00:00:00+00 | 2 days 06:05:00 | 2 days 06:05:00
```
25 changes: 25 additions & 0 deletions extension/src/accessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,33 @@ accessor! { open_time() }
accessor! { high_time() }
accessor! { low_time() }
accessor! { close_time() }
accessor! { live_ranges() }
accessor! { dead_ranges() }
accessor! { uptime() }
accessor! { downtime() }

// The rest are more complex, with String or other challenges. Leaving alone for now.

pg_type! {
#[derive(Debug)]
struct AccessorLiveAt {
time: u64,
}
}

ron_inout_funcs!(AccessorLiveAt);

#[pg_extern(immutable, parallel_safe, name = "live_at")]
pub fn accessor_live_at(ts: crate::raw::TimestampTz) -> AccessorLiveAt<'static> {
unsafe {
flatten! {
AccessorLiveAt {
time: ts.0.value() as u64,
}
}
}
}

pg_type! {
#[derive(Debug)]
struct AccessorStdDev<'input> {
Expand Down
Loading