Skip to content

Commit dd0a0ee

Browse files
author
Brian Rowe
committed
adding some tests and changelog message
1 parent 357faab commit dd0a0ee

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ This changelog should be updated as part of a PR if the work is worth noting (mo
77
## Next Release (Date TBD)
88

99
#### New experimental features
10-
- [#615](https://github.com/timescale/timescaledb-toolkit/pull/614): Heatbeat aggregate
10+
- [#615](https://github.com/timescale/timescaledb-toolkit/pull/615): Heatbeat aggregate
1111
Users can use the new `heartbeat_agg(timestamp, start_time, agg_interval, heartbeat_interval)` to track the liveness of a system in the range (`start_time`, `start_time` + `agg_interval`). Each timestamp seen in that range is assumed to indicate system liveness for the following `heartbeat_interval`.
1212
Once constructed, users can query heartbeat aggregates for `uptime` and `downtime`, as well as query for `live_ranges` or `dead_ranges`. Users can also check for `live_at(timestamp)`.
1313
Heartbeat aggregates can also interpolated to better see behavior around the boundaries of the individual aggregates.
1414

15+
- [#635](https://github.com/timescale/timescaledb-toolkit/pull/635): AsOf joins for timevectors
16+
This allows users to join two timevectors with the following semantics `timevectorA -> asof(timevectorB)`. This will return records with the LOCF value from timevectorA at the timestamps from timevectorB. Specifically the returned records contain, for each value in timevectorB, {the LOCF value from timevectorA, the value from timevectorB, the timestamp from timevectorB}.
17+
1518
#### Bug fixes
1619
- [#624](https://github.com/timescale/timescaledb-toolkit/pull/624): Remove partial aggregation for Candlestick aggregates.
1720
We've determined that the cause for the bad results lives somewhere in the functions that are used to support partial aggregation.

extension/src/time_vector.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,4 +775,44 @@ mod tests {
775775
assert!(result.next().is_none());
776776
})
777777
}
778+
779+
#[pg_test(error = "both timevectors must be populated for an asof join")]
780+
fn test_asof_none() {
781+
Spi::execute(|client| {
782+
client.select("SET timezone TO 'UTC'", None, None);
783+
784+
client.select(
785+
"WITH s as (
786+
SELECT timevector(now(), 0) -> toolkit_experimental.filter($$ $value != 0 $$) AS empty),
787+
t as (
788+
SELECT timevector(time, value) AS valid FROM
789+
(VALUES
790+
('2022-10-1 0:30 UTC'::TIMESTAMPTZ, 15.0),
791+
('2022-10-1 2:00 UTC'::TIMESTAMPTZ, 45.0),
792+
('2022-10-1 3:30 UTC'::TIMESTAMPTZ, 60.0)
793+
) as v(time, value))
794+
SELECT (valid -> toolkit_experimental.asof(empty))
795+
FROM s, t;", None, None);
796+
})
797+
}
798+
799+
#[pg_test(error = "both timevectors must be populated for an asof join")]
800+
fn test_none_asof() {
801+
Spi::execute(|client| {
802+
client.select("SET timezone TO 'UTC'", None, None);
803+
804+
client.select(
805+
"WITH s as (
806+
SELECT timevector(now(), 0) -> toolkit_experimental.filter($$ $value != 0 $$) AS empty),
807+
t as (
808+
SELECT timevector(time, value) AS valid FROM
809+
(VALUES
810+
('2022-10-1 0:30 UTC'::TIMESTAMPTZ, 15.0),
811+
('2022-10-1 2:00 UTC'::TIMESTAMPTZ, 45.0),
812+
('2022-10-1 3:30 UTC'::TIMESTAMPTZ, 60.0)
813+
) as v(time, value))
814+
SELECT (empty -> toolkit_experimental.asof(valid))
815+
FROM s, t;", None, None);
816+
})
817+
}
778818
}

0 commit comments

Comments
 (0)