Skip to content

Commit 039667b

Browse files
authored
add timescale test (#1171)
1 parent e4aeadb commit 039667b

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

nix/tests/expected/timescale.out

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- Create schema v
2+
create schema v;
3+
-- Create a table in the v schema
4+
create table v.sensor_data (
5+
time timestamptz not null,
6+
sensor_id int not null,
7+
temperature double precision not null,
8+
humidity double precision not null
9+
);
10+
-- Convert the table to a hypertable
11+
select create_hypertable('v.sensor_data', 'time');
12+
create_hypertable
13+
---------------------
14+
(1,v,sensor_data,t)
15+
(1 row)
16+
17+
-- Insert some data into the hypertable
18+
insert into v.sensor_data (time, sensor_id, temperature, humidity)
19+
values
20+
('2024-08-09', 1, 22.5, 60.2),
21+
('2024-08-08', 1, 23.0, 59.1),
22+
('2024-08-07', 2, 21.7, 63.3);
23+
-- Select data from the hypertable
24+
select
25+
*
26+
from
27+
v.sensor_data;
28+
time | sensor_id | temperature | humidity
29+
------------------------------+-----------+-------------+----------
30+
Fri Aug 09 00:00:00 2024 PDT | 1 | 22.5 | 60.2
31+
Thu Aug 08 00:00:00 2024 PDT | 1 | 23 | 59.1
32+
Wed Aug 07 00:00:00 2024 PDT | 2 | 21.7 | 63.3
33+
(3 rows)
34+
35+
-- Drop schema v and all its entities
36+
drop schema v cascade;
37+
NOTICE: drop cascades to 3 other objects
38+
DETAIL: drop cascades to table v.sensor_data
39+
drop cascades to table _timescaledb_internal._hyper_1_1_chunk
40+
drop cascades to table _timescaledb_internal._hyper_1_2_chunk

nix/tests/sql/timescale.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- Create schema v
2+
create schema v;
3+
4+
-- Create a table in the v schema
5+
create table v.sensor_data (
6+
time timestamptz not null,
7+
sensor_id int not null,
8+
temperature double precision not null,
9+
humidity double precision not null
10+
);
11+
12+
-- Convert the table to a hypertable
13+
select create_hypertable('v.sensor_data', 'time');
14+
15+
-- Insert some data into the hypertable
16+
insert into v.sensor_data (time, sensor_id, temperature, humidity)
17+
values
18+
('2024-08-09', 1, 22.5, 60.2),
19+
('2024-08-08', 1, 23.0, 59.1),
20+
('2024-08-07', 2, 21.7, 63.3);
21+
22+
-- Select data from the hypertable
23+
select
24+
*
25+
from
26+
v.sensor_data;
27+
28+
-- Drop schema v and all its entities
29+
drop schema v cascade;
30+

0 commit comments

Comments
 (0)