supabase-postgres.git / summary / log / commit / refs
commit 039667b2d43a4a7716fa588cb0b0599be732776a
Author: Oliver Rice <github@oliverrice.com>
Commit: GitHub <noreply@github.com>
Date: Fri Aug 23 17:12:48 2024 +0000
add timescale test (#1171)
nix/tests/expected/timescale.out | 40 ++++++++++++++++++++++++++++++++++++++++
nix/tests/sql/timescale.sql | 30 ++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+)
diff --git a/nix/tests/expected/timescale.out b/nix/tests/expected/timescale.out
new file mode 100644
index 00000000..d32b8e9f
--- /dev/null
+++ b/nix/tests/expected/timescale.out
@@ -0,0 +1,40 @@
+-- Create schema v
+create schema v;
+-- Create a table in the v schema
+create table v.sensor_data (
+ time timestamptz not null,
+ sensor_id int not null,
+ temperature double precision not null,
+ humidity double precision not null
+);
+-- Convert the table to a hypertable
+select create_hypertable('v.sensor_data', 'time');
+ create_hypertable
+---------------------
+ (1,v,sensor_data,t)
+(1 row)
+
+-- Insert some data into the hypertable
+insert into v.sensor_data (time, sensor_id, temperature, humidity)
+values
+ ('2024-08-09', 1, 22.5, 60.2),
+ ('2024-08-08', 1, 23.0, 59.1),
+ ('2024-08-07', 2, 21.7, 63.3);
+-- Select data from the hypertable
+select
+ *
+from
+ v.sensor_data;
+ time | sensor_id | temperature | humidity
+------------------------------+-----------+-------------+----------
+ Fri Aug 09 00:00:00 2024 PDT | 1 | 22.5 | 60.2
+ Thu Aug 08 00:00:00 2024 PDT | 1 | 23 | 59.1
+ Wed Aug 07 00:00:00 2024 PDT | 2 | 21.7 | 63.3
+(3 rows)
+
+-- Drop schema v and all its entities
+drop schema v cascade;
+NOTICE: drop cascades to 3 other objects
+DETAIL: drop cascades to table v.sensor_data
+drop cascades to table _timescaledb_internal._hyper_1_1_chunk
+drop cascades to table _timescaledb_internal._hyper_1_2_chunk
diff --git a/nix/tests/sql/timescale.sql b/nix/tests/sql/timescale.sql
new file mode 100644
index 00000000..939612a4
--- /dev/null
+++ b/nix/tests/sql/timescale.sql
@@ -0,0 +1,30 @@
+-- Create schema v
+create schema v;
+
+-- Create a table in the v schema
+create table v.sensor_data (
+ time timestamptz not null,
+ sensor_id int not null,
+ temperature double precision not null,
+ humidity double precision not null
+);
+
+-- Convert the table to a hypertable
+select create_hypertable('v.sensor_data', 'time');
+
+-- Insert some data into the hypertable
+insert into v.sensor_data (time, sensor_id, temperature, humidity)
+values
+ ('2024-08-09', 1, 22.5, 60.2),
+ ('2024-08-08', 1, 23.0, 59.1),
+ ('2024-08-07', 2, 21.7, 63.3);
+
+-- Select data from the hypertable
+select
+ *
+from
+ v.sensor_data;
+
+-- Drop schema v and all its entities
+drop schema v cascade;
+
[parent: e4aeadb4e558]