Skip to content

Commit

Permalink
Merge #722
Browse files Browse the repository at this point in the history
722: Stabilize heartbeat aggregate r=WireBaron a=WireBaron

This PR remove the toolkit_experimental namespace from heartbeat_agg and adds a great deal of testing required by our stability process.

Co-authored-by: Brian Rowe <brian@timescale.com>
  • Loading branch information
bors[bot] and Brian Rowe authored Mar 6, 2023
2 parents 4197125 + 79870af commit 27d77f6
Show file tree
Hide file tree
Showing 7 changed files with 1,037 additions and 217 deletions.
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

0 comments on commit 27d77f6

Please sign in to comment.