mirror of https://github.com/citusdata/citus.git
Improve and fix table creation tests
parent
3a9008a79c
commit
d1331055d4
|
@ -12,6 +12,8 @@ DECLARE
|
||||||
current_partition_count int;
|
current_partition_count int;
|
||||||
table_partition_interval INTERVAL;
|
table_partition_interval INTERVAL;
|
||||||
table_partition_column_type_name text;
|
table_partition_column_type_name text;
|
||||||
|
manual_partition_from_value_text text;
|
||||||
|
manual_partition_to_value_text text;
|
||||||
current_range_from_value timestamptz := NULL;
|
current_range_from_value timestamptz := NULL;
|
||||||
current_range_to_value timestamptz := NULL;
|
current_range_to_value timestamptz := NULL;
|
||||||
current_range_from_value_text text;
|
current_range_from_value_text text;
|
||||||
|
@ -146,15 +148,18 @@ BEGIN
|
||||||
* Check whether any other partition covers from_value or to_value
|
* Check whether any other partition covers from_value or to_value
|
||||||
* That means some partitions have been created manually and we must error out.
|
* That means some partitions have been created manually and we must error out.
|
||||||
*/
|
*/
|
||||||
PERFORM * FROM pg_catalog.time_partitions
|
SELECT from_value::text, to_value::text
|
||||||
|
INTO manual_partition_from_value_text, manual_partition_to_value_text
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
WHERE
|
WHERE
|
||||||
((current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR
|
((current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR
|
||||||
(current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz)) AND
|
(current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz)) AND
|
||||||
parent_table = table_name;
|
parent_table = table_name;
|
||||||
|
|
||||||
IF found THEN
|
IF found THEN
|
||||||
RAISE 'Partition with the range from % to % has been created manually. Please remove all manually created partitions to use the table as timeseries table',
|
RAISE 'Partition with the range from % to % has been created manually. Please remove all manually created partitions to use the table as timeseries table',
|
||||||
current_range_from_value::text,
|
manual_partition_from_value_text,
|
||||||
current_range_to_value::text;
|
manual_partition_to_value_text;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -12,6 +12,8 @@ DECLARE
|
||||||
current_partition_count int;
|
current_partition_count int;
|
||||||
table_partition_interval INTERVAL;
|
table_partition_interval INTERVAL;
|
||||||
table_partition_column_type_name text;
|
table_partition_column_type_name text;
|
||||||
|
manual_partition_from_value_text text;
|
||||||
|
manual_partition_to_value_text text;
|
||||||
current_range_from_value timestamptz := NULL;
|
current_range_from_value timestamptz := NULL;
|
||||||
current_range_to_value timestamptz := NULL;
|
current_range_to_value timestamptz := NULL;
|
||||||
current_range_from_value_text text;
|
current_range_from_value_text text;
|
||||||
|
@ -146,15 +148,18 @@ BEGIN
|
||||||
* Check whether any other partition covers from_value or to_value
|
* Check whether any other partition covers from_value or to_value
|
||||||
* That means some partitions have been created manually and we must error out.
|
* That means some partitions have been created manually and we must error out.
|
||||||
*/
|
*/
|
||||||
PERFORM * FROM pg_catalog.time_partitions
|
SELECT from_value::text, to_value::text
|
||||||
|
INTO manual_partition_from_value_text, manual_partition_to_value_text
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
WHERE
|
WHERE
|
||||||
((current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR
|
((current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR
|
||||||
(current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz)) AND
|
(current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz)) AND
|
||||||
parent_table = table_name;
|
parent_table = table_name;
|
||||||
|
|
||||||
IF found THEN
|
IF found THEN
|
||||||
RAISE 'Partition with the range from % to % has been created manually. Please remove all manually created partitions to use the table as timeseries table',
|
RAISE 'Partition with the range from % to % has been created manually. Please remove all manually created partitions to use the table as timeseries table',
|
||||||
current_range_from_value::text,
|
manual_partition_from_value_text,
|
||||||
current_range_to_value::text;
|
manual_partition_to_value_text;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -94,7 +94,7 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 year 1 mont
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
DROP TABLE date_partitioned_table;
|
DROP TABLE date_partitioned_table;
|
||||||
-- 2) retention threshold must be greater than compression threshold and
|
-- 2) retention threshold must be greater than compression threshold and
|
||||||
-- compresstion threshold must be greater than partition interval
|
-- compression threshold must be greater than partition interval
|
||||||
-- With date partitioned table
|
-- With date partitioned table
|
||||||
CREATE TABLE ts_comp_date_partitioned_table(
|
CREATE TABLE ts_comp_date_partitioned_table(
|
||||||
measureid integer,
|
measureid integer,
|
||||||
|
@ -264,21 +264,21 @@ FROM pg_catalog.time_partitions
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
partition | from_diff | to_diff
|
partition | from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
range_check_test_partitioned_table_0 | @ 7 hours | @ 6 hours
|
range_check_test_partit_2021_08_31_20_00_00_2021_08_31_21_00_00 | @ 7 hours | @ 6 hours
|
||||||
range_check_test_partitioned_table_1 | @ 6 hours | @ 5 hours
|
range_check_test_partit_2021_08_31_21_00_00_2021_08_31_22_00_00 | @ 6 hours | @ 5 hours
|
||||||
range_check_test_partitioned_table_2 | @ 5 hours | @ 4 hours
|
range_check_test_partit_2021_08_31_22_00_00_2021_08_31_23_00_00 | @ 5 hours | @ 4 hours
|
||||||
range_check_test_partitioned_table_3 | @ 4 hours | @ 3 hours
|
range_check_test_partit_2021_08_31_23_00_00_2021_09_01_00_00_00 | @ 4 hours | @ 3 hours
|
||||||
range_check_test_partitioned_table_4 | @ 3 hours | @ 2 hours
|
range_check_test_partit_2021_09_01_00_00_00_2021_09_01_01_00_00 | @ 3 hours | @ 2 hours
|
||||||
range_check_test_partitioned_table_5 | @ 2 hours | @ 1 hour
|
range_check_test_partit_2021_09_01_01_00_00_2021_09_01_02_00_00 | @ 2 hours | @ 1 hour
|
||||||
range_check_test_partitioned_table_6 | @ 1 hour | @ 0
|
range_check_test_partit_2021_09_01_02_00_00_2021_09_01_03_00_00 | @ 1 hour | @ 0
|
||||||
range_check_test_partitioned_table_7 | @ 0 | @ 1 hour ago
|
range_check_test_partit_2021_09_01_03_00_00_2021_09_01_04_00_00 | @ 0 | @ 1 hour ago
|
||||||
range_check_test_partitioned_table_8 | @ 1 hour ago | @ 2 hours ago
|
range_check_test_partit_2021_09_01_04_00_00_2021_09_01_05_00_00 | @ 1 hour ago | @ 2 hours ago
|
||||||
range_check_test_partitioned_table_9 | @ 2 hours ago | @ 3 hours ago
|
range_check_test_partit_2021_09_01_05_00_00_2021_09_01_06_00_00 | @ 2 hours ago | @ 3 hours ago
|
||||||
range_check_test_partitioned_table_10 | @ 3 hours ago | @ 4 hours ago
|
range_check_test_partit_2021_09_01_06_00_00_2021_09_01_07_00_00 | @ 3 hours ago | @ 4 hours ago
|
||||||
range_check_test_partitioned_table_11 | @ 4 hours ago | @ 5 hours ago
|
range_check_test_partit_2021_09_01_07_00_00_2021_09_01_08_00_00 | @ 4 hours ago | @ 5 hours ago
|
||||||
range_check_test_partitioned_table_12 | @ 5 hours ago | @ 6 hours ago
|
range_check_test_partit_2021_09_01_08_00_00_2021_09_01_09_00_00 | @ 5 hours ago | @ 6 hours ago
|
||||||
range_check_test_partitioned_table_13 | @ 6 hours ago | @ 7 hours ago
|
range_check_test_partit_2021_09_01_09_00_00_2021_09_01_10_00_00 | @ 6 hours ago | @ 7 hours ago
|
||||||
range_check_test_partitioned_table_14 | @ 7 hours ago | @ 8 hours ago
|
range_check_test_partit_2021_09_01_10_00_00_2021_09_01_11_00_00 | @ 7 hours ago | @ 8 hours ago
|
||||||
(15 rows)
|
(15 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -296,19 +296,19 @@ FROM pg_catalog.time_partitions
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
partition | from_diff | to_diff
|
partition | from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
range_check_test_partitioned_table_0 | @ 7 days | @ 6 days
|
range_check_test_partit_2021_08_25_00_00_00_2021_08_26_00_00_00 | @ 7 days | @ 6 days
|
||||||
range_check_test_partitioned_table_1 | @ 6 days | @ 5 days
|
range_check_test_partit_2021_08_26_00_00_00_2021_08_27_00_00_00 | @ 6 days | @ 5 days
|
||||||
range_check_test_partitioned_table_2 | @ 5 days | @ 4 days
|
range_check_test_partit_2021_08_27_00_00_00_2021_08_28_00_00_00 | @ 5 days | @ 4 days
|
||||||
range_check_test_partitioned_table_3 | @ 4 days | @ 3 days
|
range_check_test_partit_2021_08_28_00_00_00_2021_08_29_00_00_00 | @ 4 days | @ 3 days
|
||||||
range_check_test_partitioned_table_4 | @ 3 days | @ 2 days
|
range_check_test_partit_2021_08_29_00_00_00_2021_08_30_00_00_00 | @ 3 days | @ 2 days
|
||||||
range_check_test_partitioned_table_5 | @ 2 days | @ 1 day
|
range_check_test_partit_2021_08_30_00_00_00_2021_08_31_00_00_00 | @ 2 days | @ 1 day
|
||||||
range_check_test_partitioned_table_6 | @ 1 day | @ 0
|
range_check_test_partit_2021_08_31_00_00_00_2021_09_01_00_00_00 | @ 1 day | @ 0
|
||||||
range_check_test_partitioned_table_7 | @ 0 | @ 1 day ago
|
range_check_test_partit_2021_09_01_00_00_00_2021_09_02_00_00_00 | @ 0 | @ 1 day ago
|
||||||
range_check_test_partitioned_table_8 | @ 1 day ago | @ 2 days ago
|
range_check_test_partit_2021_09_02_00_00_00_2021_09_03_00_00_00 | @ 1 day ago | @ 2 days ago
|
||||||
range_check_test_partitioned_table_9 | @ 2 days ago | @ 3 days ago
|
range_check_test_partit_2021_09_03_00_00_00_2021_09_04_00_00_00 | @ 2 days ago | @ 3 days ago
|
||||||
range_check_test_partitioned_table_10 | @ 3 days ago | @ 4 days ago
|
range_check_test_partit_2021_09_04_00_00_00_2021_09_05_00_00_00 | @ 3 days ago | @ 4 days ago
|
||||||
range_check_test_partitioned_table_11 | @ 4 days ago | @ 5 days ago
|
range_check_test_partit_2021_09_05_00_00_00_2021_09_06_00_00_00 | @ 4 days ago | @ 5 days ago
|
||||||
range_check_test_partitioned_table_12 | @ 5 days ago | @ 6 days ago
|
range_check_test_partit_2021_09_06_00_00_00_2021_09_07_00_00_00 | @ 5 days ago | @ 6 days ago
|
||||||
(13 rows)
|
(13 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -326,17 +326,17 @@ FROM pg_catalog.time_partitions
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
partition | from_diff | to_diff
|
partition | from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
range_check_test_partitioned_table_0 | @ 21 days | @ 14 days
|
range_check_test_partit_2021_08_09_00_00_00_2021_08_16_00_00_00 | @ 21 days | @ 14 days
|
||||||
range_check_test_partitioned_table_1 | @ 14 days | @ 7 days
|
range_check_test_partit_2021_08_16_00_00_00_2021_08_23_00_00_00 | @ 14 days | @ 7 days
|
||||||
range_check_test_partitioned_table_2 | @ 7 days | @ 0
|
range_check_test_partit_2021_08_23_00_00_00_2021_08_30_00_00_00 | @ 7 days | @ 0
|
||||||
range_check_test_partitioned_table_3 | @ 0 | @ 7 days ago
|
range_check_test_partit_2021_08_30_00_00_00_2021_09_06_00_00_00 | @ 0 | @ 7 days ago
|
||||||
range_check_test_partitioned_table_4 | @ 7 days ago | @ 14 days ago
|
range_check_test_partit_2021_09_06_00_00_00_2021_09_13_00_00_00 | @ 7 days ago | @ 14 days ago
|
||||||
range_check_test_partitioned_table_5 | @ 14 days ago | @ 21 days ago
|
range_check_test_partit_2021_09_13_00_00_00_2021_09_20_00_00_00 | @ 14 days ago | @ 21 days ago
|
||||||
range_check_test_partitioned_table_6 | @ 21 days ago | @ 28 days ago
|
range_check_test_partit_2021_09_20_00_00_00_2021_09_27_00_00_00 | @ 21 days ago | @ 28 days ago
|
||||||
range_check_test_partitioned_table_7 | @ 28 days ago | @ 35 days ago
|
range_check_test_partit_2021_09_27_00_00_00_2021_10_04_00_00_00 | @ 28 days ago | @ 35 days ago
|
||||||
range_check_test_partitioned_table_8 | @ 35 days ago | @ 42 days ago
|
range_check_test_partit_2021_10_04_00_00_00_2021_10_11_00_00_00 | @ 35 days ago | @ 42 days ago
|
||||||
range_check_test_partitioned_table_9 | @ 42 days ago | @ 49 days ago
|
range_check_test_partit_2021_10_11_00_00_00_2021_10_18_00_00_00 | @ 42 days ago | @ 49 days ago
|
||||||
range_check_test_partitioned_table_10 | @ 49 days ago | @ 56 days ago
|
range_check_test_partit_2021_10_18_00_00_00_2021_10_25_00_00_00 | @ 49 days ago | @ 56 days ago
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -354,18 +354,18 @@ FROM pg_catalog.time_partitions
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
partition | from_diff | to_diff
|
partition | from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
range_check_test_partitioned_table_0 | @ 28 days | @ 21 days
|
range_check_test_partit_2021_08_02_00_00_00_2021_08_09_00_00_00 | @ 28 days | @ 21 days
|
||||||
range_check_test_partitioned_table_1 | @ 21 days | @ 14 days
|
range_check_test_partit_2021_08_09_00_00_00_2021_08_16_00_00_00 | @ 21 days | @ 14 days
|
||||||
range_check_test_partitioned_table_2 | @ 14 days | @ 7 days
|
range_check_test_partit_2021_08_16_00_00_00_2021_08_23_00_00_00 | @ 14 days | @ 7 days
|
||||||
range_check_test_partitioned_table_3 | @ 7 days | @ 0
|
range_check_test_partit_2021_08_23_00_00_00_2021_08_30_00_00_00 | @ 7 days | @ 0
|
||||||
range_check_test_partitioned_table_4 | @ 0 | @ 7 days ago
|
range_check_test_partit_2021_08_30_00_00_00_2021_09_06_00_00_00 | @ 0 | @ 7 days ago
|
||||||
range_check_test_partitioned_table_5 | @ 7 days ago | @ 14 days ago
|
range_check_test_partit_2021_09_06_00_00_00_2021_09_13_00_00_00 | @ 7 days ago | @ 14 days ago
|
||||||
range_check_test_partitioned_table_6 | @ 14 days ago | @ 21 days ago
|
range_check_test_partit_2021_09_13_00_00_00_2021_09_20_00_00_00 | @ 14 days ago | @ 21 days ago
|
||||||
range_check_test_partitioned_table_7 | @ 21 days ago | @ 28 days ago
|
range_check_test_partit_2021_09_20_00_00_00_2021_09_27_00_00_00 | @ 21 days ago | @ 28 days ago
|
||||||
range_check_test_partitioned_table_8 | @ 28 days ago | @ 35 days ago
|
range_check_test_partit_2021_09_27_00_00_00_2021_10_04_00_00_00 | @ 28 days ago | @ 35 days ago
|
||||||
range_check_test_partitioned_table_9 | @ 35 days ago | @ 42 days ago
|
range_check_test_partit_2021_10_04_00_00_00_2021_10_11_00_00_00 | @ 35 days ago | @ 42 days ago
|
||||||
range_check_test_partitioned_table_10 | @ 42 days ago | @ 49 days ago
|
range_check_test_partit_2021_10_11_00_00_00_2021_10_18_00_00_00 | @ 42 days ago | @ 49 days ago
|
||||||
range_check_test_partitioned_table_11 | @ 49 days ago | @ 56 days ago
|
range_check_test_partit_2021_10_18_00_00_00_2021_10_25_00_00_00 | @ 49 days ago | @ 56 days ago
|
||||||
(12 rows)
|
(12 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -416,3 +416,49 @@ SELECT * FROM timeseries.tables;
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
-- Check distributed partitioned table
|
||||||
|
CREATE TABLE distributed_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
SELECT create_distributed_table('distributed_partitioned_table', 'measureid');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_timeseries_table('distributed_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM timeseries.tables;
|
||||||
|
logicalrelid | partitioninterval | postmakeintervalcount | premakeintervalcount | startfrom | compressionthreshold | retentionthreshold
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
distributed_partitioned_table | @ 1 day | 7 | 7 | | |
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- We should have 512 shards since we have 15 partitions and 1 parent table
|
||||||
|
SELECT count(*)
|
||||||
|
FROM pg_dist_shard
|
||||||
|
WHERE logicalrelid::text LIKE 'distributed_partitioned_table%';
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
64
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE distributed_partitioned_table;
|
||||||
|
SELECT * FROM timeseries.tables;
|
||||||
|
logicalrelid | partitioninterval | postmakeintervalcount | premakeintervalcount | startfrom | compressionthreshold | retentionthreshold
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- Show that partitioned reference tables are not supported
|
||||||
|
CREATE TABLE partitioned_reference_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
SELECT create_reference_table('partitioned_reference_table');
|
||||||
|
ERROR: distributing partitioned tables in only supported for hash-distributed tables
|
||||||
|
DROP TABLE partitioned_reference_table;
|
||||||
|
|
|
@ -724,10 +724,9 @@ BEGIN;
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM pg_catalog.time_partitions
|
FROM pg_catalog.time_partitions
|
||||||
WHERE parent_table = 'absolute_times_partitioned_table'::regclass
|
WHERE parent_table = 'absolute_times_partitioned_table'::regclass
|
||||||
ORDER BY 1,2,3;
|
ORDER BY 3;
|
||||||
parent_table | partition_column | partition | from_value | to_value | access_method
|
parent_table | partition_column | partition | from_value | to_value | access_method
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_01_01_2021_02_01 | 01-01-2021 | 02-01-2021 | heap
|
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_02_01_2021_03_01 | 02-01-2021 | 03-01-2021 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_02_01_2021_03_01 | 02-01-2021 | 03-01-2021 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_03_01_2021_04_01 | 03-01-2021 | 04-01-2021 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_03_01_2021_04_01 | 03-01-2021 | 04-01-2021 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_04_01_2021_05_01 | 04-01-2021 | 05-01-2021 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_04_01_2021_05_01 | 04-01-2021 | 05-01-2021 | heap
|
||||||
|
@ -742,6 +741,7 @@ BEGIN;
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_01_01_2022_02_01 | 01-01-2022 | 02-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_01_01_2022_02_01 | 01-01-2022 | 02-01-2022 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_02_01_2022_03_01 | 02-01-2022 | 03-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_02_01_2022_03_01 | 02-01-2022 | 03-01-2022 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_03_01_2022_04_01 | 03-01-2022 | 04-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_03_01_2022_04_01 | 03-01-2022 | 04-01-2022 | heap
|
||||||
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_04_01_2022_05_01 | 04-01-2022 | 05-01-2022 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_01_01_2020_02_01 | 01-01-2020 | 02-01-2020 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_01_01_2020_02_01 | 01-01-2020 | 02-01-2020 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_02_01_2020_03_01 | 02-01-2020 | 03-01-2020 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_02_01_2020_03_01 | 02-01-2020 | 03-01-2020 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_03_01_2020_04_01 | 03-01-2020 | 04-01-2020 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_03_01_2020_04_01 | 03-01-2020 | 04-01-2020 | heap
|
||||||
|
@ -754,7 +754,7 @@ BEGIN;
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_10_01_2020_11_01 | 10-01-2020 | 11-01-2020 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_10_01_2020_11_01 | 10-01-2020 | 11-01-2020 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_11_01_2020_12_01 | 11-01-2020 | 12-01-2020 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_11_01_2020_12_01 | 11-01-2020 | 12-01-2020 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_12_01_2021_01_01 | 12-01-2020 | 01-01-2021 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2020_12_01_2021_01_01 | 12-01-2020 | 01-01-2021 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_04_01_2022_05_01 | 04-01-2022 | 05-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2021_01_01_2021_02_01 | 01-01-2021 | 02-01-2021 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_05_01_2022_06_01 | 05-01-2022 | 06-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_05_01_2022_06_01 | 05-01-2022 | 06-01-2022 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_06_01_2022_07_01 | 06-01-2022 | 07-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_06_01_2022_07_01 | 06-01-2022 | 07-01-2022 | heap
|
||||||
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_07_01_2022_08_01 | 07-01-2022 | 08-01-2022 | heap
|
absolute_times_partitioned_table | eventdate | absolute_times_partitioned_table_2022_07_01_2022_08_01 | 07-01-2022 | 08-01-2022 | heap
|
||||||
|
|
|
@ -110,14 +110,14 @@ BEGIN;
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE date_partitioned_table_manual_partition PARTITION OF date_partitioned_table FOR VALUES FROM (now() + INTERVAL '15 days') TO (now() + INTERVAL '30 days');
|
CREATE TABLE date_partitioned_table_manual_partition PARTITION OF date_partitioned_table FOR VALUES FROM '2030-01-01'::date TO '2040-01-01'::date;
|
||||||
|
ERROR: syntax error at or near "'2030-01-01'"
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '20 days', now() - INTERVAL '20 days')
|
FROM get_missing_partition_ranges('date_partitioned_table', '2031-01-01'::date, '2021-01-01'::date)
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
ERROR: Partition with the range from Wed Sep 15 00:00:00 2021 PDT to Thu Sep 16 00:00:00 2021 PDT has been created manually. Please remove all manually created partitions to use the table as timeseries table
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
CONTEXT: PL/pgSQL function get_missing_partition_ranges(regclass,timestamp with time zone,timestamp with time zone) line XX at RAISE
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
DROP TABLE date_partitioned_table;
|
DROP TABLE date_partitioned_table;
|
||||||
-- Show range values for timestamptz partitioned table
|
-- Show range values for timestamptz partitioned table
|
||||||
|
@ -300,14 +300,14 @@ BEGIN;
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE tstz_partitioned_table_manual_partition PARTITION OF tstz_partitioned_table FOR VALUES FROM (now() + INTERVAL '15 days') TO (now() + INTERVAL '30 days');
|
CREATE TABLE tstz_partitioned_table_manual_partition PARTITION OF tstz_partitioned_table FOR VALUES FROM '2030-01-01'::timestamptz TO '2040-01-01'::timestamptz;
|
||||||
|
ERROR: syntax error at or near "'2030-01-01'"
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '20 days', now() - INTERVAL '20 days')
|
FROM get_missing_partition_ranges('tstz_partitioned_table', '2031-01-01'::timestamptz, '2021-01-01'::timestamptz)
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
ERROR: Partition with the range from Wed Sep 15 00:00:00 2021 PDT to Thu Sep 16 00:00:00 2021 PDT has been created manually. Please remove all manually created partitions to use the table as timeseries table
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
CONTEXT: PL/pgSQL function get_missing_partition_ranges(regclass,timestamp with time zone,timestamp with time zone) line XX at RAISE
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- Test with different time zones
|
-- Test with different time zones
|
||||||
SET timezone TO 'UTC';
|
SET timezone TO 'UTC';
|
||||||
|
|
|
@ -238,3 +238,30 @@ BEGIN;
|
||||||
DROP TABLE drop_check_test_partitioned_table;
|
DROP TABLE drop_check_test_partitioned_table;
|
||||||
SELECT * FROM timeseries.tables;
|
SELECT * FROM timeseries.tables;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
-- Check distributed partitioned table
|
||||||
|
CREATE TABLE distributed_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
|
||||||
|
SELECT create_distributed_table('distributed_partitioned_table', 'measureid');
|
||||||
|
SELECT create_timeseries_table('distributed_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT * FROM timeseries.tables;
|
||||||
|
|
||||||
|
-- We should have 512 shards since we have 15 partitions and 1 parent table
|
||||||
|
SELECT count(*)
|
||||||
|
FROM pg_dist_shard
|
||||||
|
WHERE logicalrelid::text LIKE 'distributed_partitioned_table%';
|
||||||
|
|
||||||
|
DROP TABLE distributed_partitioned_table;
|
||||||
|
SELECT * FROM timeseries.tables;
|
||||||
|
|
||||||
|
-- Show that partitioned reference tables are not supported
|
||||||
|
CREATE TABLE partitioned_reference_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
|
||||||
|
SELECT create_reference_table('partitioned_reference_table');
|
||||||
|
DROP TABLE partitioned_reference_table;
|
||||||
|
|
|
@ -205,7 +205,7 @@ BEGIN;
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM pg_catalog.time_partitions
|
FROM pg_catalog.time_partitions
|
||||||
WHERE parent_table = 'absolute_times_partitioned_table'::regclass
|
WHERE parent_table = 'absolute_times_partitioned_table'::regclass
|
||||||
ORDER BY 1,2,3;
|
ORDER BY 3;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
DROP TABLE absolute_times_partitioned_table;
|
DROP TABLE absolute_times_partitioned_table;
|
||||||
|
|
|
@ -47,11 +47,11 @@ ROLLBACK;
|
||||||
-- Show that table must not have manual partitions
|
-- Show that table must not have manual partitions
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
CREATE TABLE date_partitioned_table_manual_partition PARTITION OF date_partitioned_table FOR VALUES FROM (now() + INTERVAL '15 days') TO (now() + INTERVAL '30 days');
|
CREATE TABLE date_partitioned_table_manual_partition PARTITION OF date_partitioned_table FOR VALUES FROM '2030-01-01'::date TO '2040-01-01'::date;
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '20 days', now() - INTERVAL '20 days')
|
FROM get_missing_partition_ranges('date_partitioned_table', '2031-01-01'::date, '2021-01-01'::date)
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
@ -112,11 +112,11 @@ ROLLBACK;
|
||||||
-- Show that table must not have manual partitions
|
-- Show that table must not have manual partitions
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
||||||
CREATE TABLE tstz_partitioned_table_manual_partition PARTITION OF tstz_partitioned_table FOR VALUES FROM (now() + INTERVAL '15 days') TO (now() + INTERVAL '30 days');
|
CREATE TABLE tstz_partitioned_table_manual_partition PARTITION OF tstz_partitioned_table FOR VALUES FROM '2030-01-01'::timestamptz TO '2040-01-01'::timestamptz;
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '20 days', now() - INTERVAL '20 days')
|
FROM get_missing_partition_ranges('tstz_partitioned_table', '2031-01-01'::timestamptz, '2021-01-01'::timestamptz)
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue