timescaledb/test/sql/agg_bookends.sql
Matvey Arye db01c84c2d Make time-bucket function parallel safe
There was no reason for it not to be parallel safe before.
2017-06-02 16:15:51 -04:00

32 lines
1.2 KiB
SQL

\ir include/create_single_db.sql
CREATE TABLE "btest"(time timestamp, time_alt timestamp, gp INTEGER, temp float, strid TEXT DEFAULT 'testing');
SELECT create_hypertable('"btest"', 'time');
INSERT INTO "btest" VALUES('2017-01-20T09:00:01', '2017-01-20T10:00:00', 1, 22.5);
INSERT INTO "btest" VALUES('2017-01-20T09:00:21', '2017-01-20T09:00:59', 1, 21.2);
INSERT INTO "btest" VALUES('2017-01-20T09:00:47', '2017-01-20T09:00:58', 1, 25.1);
INSERT INTO "btest" VALUES('2017-01-20T09:00:02', '2017-01-20T09:00:57', 2, 35.5);
INSERT INTO "btest" VALUES('2017-01-20T09:00:21', '2017-01-20T09:00:56', 2, 30.2);
--TOASTED;
INSERT INTO "btest" VALUES('2017-01-20T09:00:43', '2017-01-20T09:00:55', 2, 20.1, repeat('xyz', 1000000) );
SELECT time, gp, temp FROM btest ORDER BY time;
SELECT last(temp, time) FROM "btest";
SELECT first(temp, time) FROM "btest";
SELECT last(temp, time_alt) FROM "btest";
SELECT first(temp, time_alt) FROM "btest";
SELECT gp, last(temp, time) FROM "btest" GROUP BY gp;
SELECT gp, first(temp, time) FROM "btest" GROUP BY gp;
SELECT gp, first("btest", time) FROM "btest" GROUP BY gp;
--check toasted col
SELECT gp, left(last(strid, time), 10) FROM "btest" GROUP BY gp;