Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for dimensions view #2419

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions tsl/test/expected/dist_views.out
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ SELECT setseed(1);

(1 row)

CREATE TABLE dist_table(time timestamptz, device int, temp float);
CREATE TABLE dist_table(time timestamptz NOT NULL, device int, temp float, timedim date NOT NULL);
SELECT create_distributed_hypertable('dist_table', 'time', 'device', replication_factor => 2);
NOTICE: adding not-null constraint to column "time"
create_distributed_hypertable
-------------------------------
(1,public,dist_table,t)
(1 row)

INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80
SELECT add_dimension('dist_table', 'timedim', chunk_time_interval=>'7 days'::interval);
add_dimension
---------------------------------
(3,public,dist_table,timedim,t)
(1 row)

INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80, '2020-01-01'
FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-04 1:00', '1 hour') t;
ALTER TABLE dist_table SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');
-- Test views with compression
Expand All @@ -65,7 +70,7 @@ SELECT * FROM timescaledb_information.hypertables
WHERE table_name = 'dist_table';
table_schema | table_name | owner | num_dimensions | num_chunks | compression_enabled | is_distributed | replication_factor | data_nodes | tablespaces
--------------+------------+-------------+----------------+------------+---------------------+----------------+--------------------+---------------------------------------+-------------
public | dist_table | test_role_1 | 2 | 3 | f | t | 2 | {view_node_1,view_node_2,view_node_3} |
public | dist_table | test_role_1 | 3 | 3 | f | t | 2 | {view_node_1,view_node_2,view_node_3} |
(1 row)

SELECT * from timescaledb_information.chunks
Expand All @@ -83,7 +88,8 @@ ORDER BY hypertable_name, dimension_number;
-------------------+-----------------+------------------+-------------+--------------------------+----------------+---------------+------------------+------------------+----------------
public | dist_table | 1 | time | timestamp with time zone | Time | @ 7 days | | |
public | dist_table | 2 | device | integer | Space | | | | 3
(2 rows)
public | dist_table | 3 | timedim | date | Time | @ 7 days | | |
(3 rows)

SELECT * FROM chunks_detailed_size('dist_table'::regclass)
ORDER BY chunk_name, node_name;
Expand Down
5 changes: 3 additions & 2 deletions tsl/test/sql/dist_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ SET client_min_messages TO NOTICE;
SET ROLE :ROLE_1;
SELECT setseed(1);

CREATE TABLE dist_table(time timestamptz, device int, temp float);
CREATE TABLE dist_table(time timestamptz NOT NULL, device int, temp float, timedim date NOT NULL);
SELECT create_distributed_hypertable('dist_table', 'time', 'device', replication_factor => 2);
INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80
SELECT add_dimension('dist_table', 'timedim', chunk_time_interval=>'7 days'::interval);
INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80, '2020-01-01'
FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-04 1:00', '1 hour') t;
ALTER TABLE dist_table SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');

Expand Down