You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgreSQL version (output of SELECT version();): 15.4-ts2.12.0
TimescaleDB Toolkit version (output of \dx timescaledb_toolkit in psql): 1.17
Installation method: docker
Describe the bug
Events are getting doubled up and not merging together properly when they span buckets, this is a similar query as what is documented here, just with a 60 minute window. The second OK record here passes the 3rd, creating extra records with invalid timeframes
To Reproduce
SETTIME ZONE 'UTC';
droptable states_test_k;
CREATETABLEstates_test_k(ts TIMESTAMPTZ, state TEXT);
INSERT INTO states_test_k VALUES
('2020-01-01 01:00:00+00', 'OK'),
('2020-01-01 01:00:01+00', 'START'),
('2020-01-01 01:00:03+00', 'OK'),
('2020-01-01 01:00:30+00', 'START'),
('2020-01-01 01:00:59+00', 'OK'),
('2020-01-01 01:01:30+00', 'START'),
('2020-01-01 01:01:59+00', 'OK'),
('2020-01-01 01:02:59+00', 'START'),
('2020-01-01 01:03:59+00', 'OK'),
('2020-01-01 02:01:59+00', 'START');
SELECT
bucket,
(interpolated_state_timeline(
summary,
bucket,
'60 min',
LAG(summary) OVER (ORDER by bucket)
)).*FROM (
SELECT
time_bucket('1 min'::interval, ts) AS bucket,
state_agg(ts, state) AS summary
FROM states_test_k
GROUP BY time_bucket('1 min'::interval, ts)
) t
order by bucket;
Expected behavior
The results should be
OK 2020-01-01 01:00:00+00 2020-01-01 01:00:01+00
START 2020-01-01 01:00:01+00 2020-01-01 01:00:03+00
OK 2020-01-01 01:00:03+00 2020-01-01 01:00:30+00
START 2020-01-01 01:00:30+00 2020-01-01 01:00:59+00
OK 2020-01-01 01:00:59+00 2020-01-01 01:01:30+00
START 2020-01-01 01:01:30+00 2020-01-01 01:01:59+00
OK 2020-01-01 01:01:59+00 2020-01-01 01:02:59+00
START 2020-01-01 01:02:59+00 2020-01-01 01:03:59+00
OK 2020-01-01 01:03:59+00 2020-01-01 02:01:59+00
START 2020-01-01 02:01:59+00 2020-01-01 02:01:59+00
Actual behavior
The results are incorrect creating invalid time ranges that pass "overlapping" time ranges. All of the double-up are correct OK-OK and START-START
Additional context
interpolated_state_timeline has the potential to be a very powerful feature. However it is producing unexpected results and I am wary of its actual performance on large datasets even if was functioning as expected.
The text was updated successfully, but these errors were encountered:
Relevant system information:
SELECT version();
): 15.4-ts2.12.0\dx timescaledb_toolkit
inpsql
): 1.17Describe the bug
Events are getting doubled up and not merging together properly when they span buckets, this is a similar query as what is documented here, just with a 60 minute window. The second OK record here passes the 3rd, creating extra records with invalid timeframes
To Reproduce
Expected behavior
The results should be
Actual behavior
The results are incorrect creating invalid time ranges that pass "overlapping" time ranges. All of the double-up are correct OK-OK and START-START
Screenshots
Additional context
interpolated_state_timeline has the potential to be a very powerful feature. However it is producing unexpected results and I am wary of its actual performance on large datasets even if was functioning as expected.
The text was updated successfully, but these errors were encountered: