diff --git a/test/expected/basic_usage.out b/test/expected/basic_usage.out index 7826867..8d7bfb4 100644 --- a/test/expected/basic_usage.out +++ b/test/expected/basic_usage.out @@ -140,9 +140,15 @@ SELECT COUNT(*) < 10 AS fewer_partitions FROM ts_part_info; CREATE TABLE events ( user_id bigint, event_id bigint, - event_time timestamptz, + event_time timestamptz NOT NULL, value float -); +) PARTITION BY RANGE (event_time); +SELECT enable_ts_table('events'); + enable_ts_table +----------------- + +(1 row) + COPY events FROM STDIN WITH (FORMAT 'csv'); SELECT first(value, event_time), user_id FROM events GROUP BY user_id; first | user_id @@ -172,3 +178,25 @@ SELECT last(event_id, event_time), user_id FROM events GROUP BY user_id; 6 | 1 (2 rows) +SELECT last(user_id, value) top_performer, + locf(avg(value)) OVER (ORDER BY event_time), + event_time +FROM date_bin_table(NULL::events, '1 minute', + '[2020-11-04 15:50:00-08, 2020-11-04 16:00:00-08]') +GROUP BY 3 +ORDER BY 3; + top_performer | locf | event_time +---------------+--------------------+------------------------------ + | | Wed Nov 04 15:50:00 2020 PST + 2 | 1.4 | Wed Nov 04 15:51:00 2020 PST + | 1.4 | Wed Nov 04 15:52:00 2020 PST + 2 | 1.5 | Wed Nov 04 15:53:00 2020 PST + | 1.5 | Wed Nov 04 15:54:00 2020 PST + 2 | 1.6 | Wed Nov 04 15:55:00 2020 PST + | 1.6 | Wed Nov 04 15:56:00 2020 PST + 2 | 1.7 | Wed Nov 04 15:57:00 2020 PST + 2 | 1.8 | Wed Nov 04 15:58:00 2020 PST + 2 | 1.9000000000000001 | Wed Nov 04 15:59:00 2020 PST + | 1.9000000000000001 | Wed Nov 04 16:00:00 2020 PST +(11 rows) + diff --git a/test/sql/basic_usage.sql b/test/sql/basic_usage.sql index 47d3d03..81a5a04 100644 --- a/test/sql/basic_usage.sql +++ b/test/sql/basic_usage.sql @@ -52,20 +52,21 @@ SELECT COUNT(*) < 10 AS fewer_partitions FROM ts_part_info; CREATE TABLE events ( user_id bigint, event_id bigint, - event_time timestamptz, + event_time timestamptz NOT NULL, value float -); +) PARTITION BY RANGE (event_time); +SELECT enable_ts_table('events'); COPY events FROM STDIN WITH (FORMAT 'csv'); -1,1,"2020-11-04 15:54:02.226999-08",1.1 -1,2,"2020-11-04 15:55:02.226999-08",1.2 -1,3,"2020-11-04 15:56:02.226999-08",1.3 +1,1,"2020-11-04 15:51:02.226999-08",1.1 +1,2,"2020-11-04 15:53:02.226999-08",1.2 +1,3,"2020-11-04 15:55:02.226999-08",1.3 1,4,"2020-11-04 15:57:02.226999-08",1.4 1,5,"2020-11-04 15:58:02.226999-08",1.5 1,6,"2020-11-04 15:59:02.226999-08",1.6 -2,7,"2020-11-04 15:54:02.226999-08",1.7 -2,8,"2020-11-04 15:55:02.226999-08",1.8 -2,9,"2020-11-04 15:56:02.226999-08",1.9 +2,7,"2020-11-04 15:51:02.226999-08",1.7 +2,8,"2020-11-04 15:53:02.226999-08",1.8 +2,9,"2020-11-04 15:55:02.226999-08",1.9 2,10,"2020-11-04 15:57:02.226999-08",2.0 2,11,"2020-11-04 15:58:02.226999-08",2.1 2,12,"2020-11-04 15:59:02.226999-08",2.2 @@ -78,3 +79,11 @@ SELECT last(value, event_time), user_id FROM events GROUP BY user_id; SELECT first(event_id, event_time), user_id FROM events GROUP BY user_id; SELECT last(event_id, event_time), user_id FROM events GROUP BY user_id; + +SELECT last(user_id, value) top_performer, + locf(avg(value)) OVER (ORDER BY event_time), + event_time +FROM date_bin_table(NULL::events, '1 minute', + '[2020-11-04 15:50:00-08, 2020-11-04 16:00:00-08]') +GROUP BY 3 +ORDER BY 3;