EditorConfig

velioglu/create_timeseries_table
Burak Velioglu 2021-08-27 12:21:45 +03:00
parent ec05df9708
commit e4fbcfe3cf
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
9 changed files with 54 additions and 46 deletions

View File

@ -29,7 +29,7 @@ BEGIN
SELECT * SELECT *
FROM get_missing_partition_ranges(table_name, to_date, start_from) FROM get_missing_partition_ranges(table_name, to_date, start_from)
LOOP LOOP
current_partition_name := table_name::text || '_' || current_partition_count::text; current_partition_name := table_name::text || '_' || current_partition_count::text;
EXECUTE format('CREATE TABLE %I PARTITION OF %I FOR VALUES FROM (''%I'') TO (''%I'')', current_partition_name, table_name::text, range_values_record.range_from_value, range_values_record.range_to_value); EXECUTE format('CREATE TABLE %I PARTITION OF %I FOR VALUES FROM (''%I'') TO (''%I'')', current_partition_name, table_name::text, range_values_record.range_from_value, range_values_record.range_to_value);
current_partition_count := current_partition_count + 1; current_partition_count := current_partition_count + 1;
END LOOP; END LOOP;

View File

@ -29,7 +29,7 @@ BEGIN
SELECT * SELECT *
FROM get_missing_partition_ranges(table_name, to_date, start_from) FROM get_missing_partition_ranges(table_name, to_date, start_from)
LOOP LOOP
current_partition_name := table_name::text || '_' || current_partition_count::text; current_partition_name := table_name::text || '_' || current_partition_count::text;
EXECUTE format('CREATE TABLE %I PARTITION OF %I FOR VALUES FROM (''%I'') TO (''%I'')', current_partition_name, table_name::text, range_values_record.range_from_value, range_values_record.range_to_value); EXECUTE format('CREATE TABLE %I PARTITION OF %I FOR VALUES FROM (''%I'') TO (''%I'')', current_partition_name, table_name::text, range_values_record.range_from_value, range_values_record.range_to_value);
current_partition_count := current_partition_count + 1; current_partition_count := current_partition_count + 1;
END LOOP; END LOOP;

View File

@ -111,7 +111,8 @@ BEGIN
* Since partition interval can be given as, we are converting all variables to timestamptz to make sure * Since partition interval can be given as, we are converting all variables to timestamptz to make sure
* that we are comparing same type of parameters * that we are comparing same type of parameters
*/ */
PERFORM * FROM pg_catalog.time_partitions WHERE from_value::timestamptz = current_range_from_value::timestamptz AND to_value::timestamptz = current_range_to_value::timestamptz; PERFORM * FROM pg_catalog.time_partitions
WHERE from_value::timestamptz = current_range_from_value::timestamptz AND to_value::timestamptz = current_range_to_value::timestamptz;
IF found THEN IF found THEN
current_range_from_value := current_range_to_value; current_range_from_value := current_range_to_value;
current_range_to_value := current_range_to_value + table_partition_interval; current_range_to_value := current_range_to_value + table_partition_interval;
@ -122,7 +123,7 @@ 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 PERFORM * FROM pg_catalog.time_partitions
WHERE (current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR WHERE (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); (current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz);
IF found THEN IF found THEN

View File

@ -111,7 +111,8 @@ BEGIN
* Since partition interval can be given as, we are converting all variables to timestamptz to make sure * Since partition interval can be given as, we are converting all variables to timestamptz to make sure
* that we are comparing same type of parameters * that we are comparing same type of parameters
*/ */
PERFORM * FROM pg_catalog.time_partitions WHERE from_value::timestamptz = current_range_from_value::timestamptz AND to_value::timestamptz = current_range_to_value::timestamptz; PERFORM * FROM pg_catalog.time_partitions
WHERE from_value::timestamptz = current_range_from_value::timestamptz AND to_value::timestamptz = current_range_to_value::timestamptz;
IF found THEN IF found THEN
current_range_from_value := current_range_to_value; current_range_from_value := current_range_to_value;
current_range_to_value := current_range_to_value + table_partition_interval; current_range_to_value := current_range_to_value + table_partition_interval;
@ -122,7 +123,7 @@ 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 PERFORM * FROM pg_catalog.time_partitions
WHERE (current_range_from_value::timestamptz > from_value::timestamptz AND current_range_from_value < to_value::timestamptz) OR WHERE (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); (current_range_to_value::timestamptz > from_value::timestamptz AND current_range_to_value::timestamptz < to_value::timestamptz);
IF found THEN IF found THEN

View File

@ -116,8 +116,11 @@ ORDER BY 1;
function create_distributed_function(regprocedure,text,text) function create_distributed_function(regprocedure,text,text)
function create_distributed_table(regclass,text,citus.distribution_type,text,integer) function create_distributed_table(regclass,text,citus.distribution_type,text,integer)
function create_intermediate_result(text,text) function create_intermediate_result(text,text)
function create_missing_partitions(regclass,timestamp with time zone,timestamp with time zone)
function create_reference_table(regclass) function create_reference_table(regclass)
function create_timeseries_table(regclass,interval,integer,integer,timestamp with time zone,interval,interval)
function distributed_tables_colocated(regclass,regclass) function distributed_tables_colocated(regclass,regclass)
function drop_timeseries_table(regclass)
function dump_global_wait_edges() function dump_global_wait_edges()
function dump_local_wait_edges() function dump_local_wait_edges()
function fetch_intermediate_results(text[],text,integer) function fetch_intermediate_results(text[],text,integer)
@ -128,6 +131,7 @@ ORDER BY 1;
function get_colocated_table_array(regclass) function get_colocated_table_array(regclass)
function get_current_transaction_id() function get_current_transaction_id()
function get_global_active_transactions() function get_global_active_transactions()
function get_missing_partition_ranges(regclass,timestamp with time zone,timestamp with time zone)
function get_rebalance_progress() function get_rebalance_progress()
function get_rebalance_table_shards_plan(regclass,real,integer,bigint[],boolean,name,real) function get_rebalance_table_shards_plan(regclass,real,integer,bigint[],boolean,name,real)
function get_shard_id_for_distribution_column(regclass,"any") function get_shard_id_for_distribution_column(regclass,"any")
@ -217,6 +221,7 @@ ORDER BY 1;
function worker_save_query_explain_analyze(text,jsonb) function worker_save_query_explain_analyze(text,jsonb)
schema citus schema citus
schema citus_internal schema citus_internal
schema citus_timeseries
schema columnar schema columnar
sequence columnar.storageid_seq sequence columnar.storageid_seq
sequence pg_dist_colocationid_seq sequence pg_dist_colocationid_seq
@ -225,6 +230,7 @@ ORDER BY 1;
sequence pg_dist_placement_placementid_seq sequence pg_dist_placement_placementid_seq
sequence pg_dist_shardid_seq sequence pg_dist_shardid_seq
table citus.pg_dist_object table citus.pg_dist_object
table citus_timeseries.citus_timeseries_tables
table columnar.chunk table columnar.chunk
table columnar.chunk_group table columnar.chunk_group
table columnar.options table columnar.options
@ -254,5 +260,5 @@ ORDER BY 1;
view citus_worker_stat_activity view citus_worker_stat_activity
view pg_dist_shard_placement view pg_dist_shard_placement
view time_partitions view time_partitions
(238 rows) (244 rows)

View File

@ -78,7 +78,7 @@ 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 -- compresstion threshold must be greater than partition interval
-- With date partitioned table -- With date partitioned table
@ -183,37 +183,37 @@ CREATE TABLE range_check_test_partitioned_table(
BEGIN; BEGIN;
SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 hour');
SELECT partition, SELECT partition,
date_trunc('hour',now()) - from_value::timestamptz as from_diff, date_trunc('hour',now()) - from_value::timestamptz as from_diff,
date_trunc('hour', now()) - to_value::timestamptz as to_diff date_trunc('hour', now()) - to_value::timestamptz as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
ORDER BY 1; ORDER BY 1;
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 day', postmake_interval_count => 5); SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 day', postmake_interval_count => 5);
SELECT partition, SELECT partition,
date_trunc('day',now()) - from_value::timestamptz as from_diff, date_trunc('day',now()) - from_value::timestamptz as from_diff,
date_trunc('day', now()) - to_value::timestamptz as to_diff date_trunc('day', now()) - to_value::timestamptz as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
ORDER BY 1; ORDER BY 1;
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 week', premake_interval_count => 3); SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 week', premake_interval_count => 3);
SELECT partition, SELECT partition,
date_trunc('week',now()) - from_value::timestamptz as from_diff, date_trunc('week',now()) - from_value::timestamptz as from_diff,
date_trunc('week', now()) - to_value::timestamptz as to_diff date_trunc('week', now()) - to_value::timestamptz as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
ORDER BY 1; ORDER BY 1;
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 week', start_from => now() - INTERVAL '4 weeks'); SELECT create_timeseries_table('range_check_test_partitioned_table', INTERVAL '1 week', start_from => now() - INTERVAL '4 weeks');
SELECT partition, SELECT partition,
date_trunc('week',now()) - from_value::timestamptz as from_diff, date_trunc('week',now()) - from_value::timestamptz as from_diff,
date_trunc('week', now()) - to_value::timestamptz as to_diff date_trunc('week', now()) - to_value::timestamptz as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
ORDER BY 1; ORDER BY 1;
ROLLBACK; ROLLBACK;

View File

@ -10,7 +10,7 @@ SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days'); SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days');
SELECT SELECT
date_trunc('day', now()) - from_value::date as from_diff, date_trunc('day', now()) - from_value::date as from_diff,
date_trunc('day', now()) - to_value::date as to_diff date_trunc('day', now()) - to_value::date as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -21,7 +21,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '10 days', now() + INTERVAL '10 days'); SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '10 days', now() + INTERVAL '10 days');
SELECT SELECT
date_trunc('day', now()) - from_value::date as from_diff, date_trunc('day', now()) - from_value::date as from_diff,
date_trunc('day', now()) - to_value::date as to_diff date_trunc('day', now()) - to_value::date as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -32,7 +32,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '45 days', now() + INTERVAL '45 days'); SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '45 days', now() + INTERVAL '45 days');
SELECT SELECT
date_trunc('day', now()) - from_value::date as from_diff, date_trunc('day', now()) - from_value::date as from_diff,
date_trunc('day', now()) - to_value::date as to_diff date_trunc('day', now()) - to_value::date as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -43,7 +43,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '65 days', now() + INTERVAL '65 days'); SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '65 days', now() + INTERVAL '65 days');
SELECT SELECT
date_trunc('day', now()) - from_value::date as from_diff, date_trunc('day', now()) - from_value::date as from_diff,
date_trunc('day', now()) - to_value::date as to_diff date_trunc('day', now()) - to_value::date as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -54,7 +54,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '5 days', now() + INTERVAL '5 days'); SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '5 days', now() + INTERVAL '5 days');
SELECT SELECT
date_trunc('day', now()) - from_value::date as from_diff, date_trunc('day', now()) - from_value::date as from_diff,
date_trunc('day', now()) - to_value::date as to_diff date_trunc('day', now()) - to_value::date as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -73,7 +73,7 @@ CREATE TABLE tstz_partitioned_table(
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day'); SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -84,7 +84,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day'); SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -95,7 +95,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours');
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day'); SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -106,7 +106,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days'); SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
SELECT SELECT
date_trunc('day', now()) - from_value::timestamp with time zone as from_diff, date_trunc('day', now()) - from_value::timestamp with time zone as from_diff,
date_trunc('day', now()) - to_value::timestamp with time zone as to_diff date_trunc('day', now()) - to_value::timestamp with time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -124,7 +124,7 @@ CREATE TABLE tswtz_partitioned_table(
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day'); SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -135,7 +135,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day'); SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -146,7 +146,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day'); SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
SELECT SELECT
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
@ -157,7 +157,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days'); SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
SELECT SELECT
date_trunc('day', now()) - from_value::timestamp without time zone as from_diff, date_trunc('day', now()) - from_value::timestamp without time zone as from_diff,
date_trunc('day', now()) - to_value::timestamp without time zone as to_diff date_trunc('day', now()) - to_value::timestamp without time zone as to_diff
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions

View File

@ -9,7 +9,7 @@ SELECT get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '
-- Show range values for data partitioned table -- Show range values for data partitioned table
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
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 '15 days') FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days')
@ -18,7 +18,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
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 '15 days', now() - INTERVAL '15 days') FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days', now() - INTERVAL '15 days')
@ -27,7 +27,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
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 '45 days', now() - INTERVAL '45 days') FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '45 days', now() - INTERVAL '45 days')
@ -36,7 +36,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
SELECT SELECT
date_trunc('week', now()) - range_from_value::date as from_diff, date_trunc('week', now()) - range_from_value::date as from_diff,
date_trunc('week', now()) - range_to_value::date as to_diff date_trunc('week', now()) - range_to_value::date as to_diff
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days') FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days')
@ -45,7 +45,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
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 '5 days', now() - INTERVAL '5 days') FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
@ -62,7 +62,7 @@ CREATE TABLE tstz_partitioned_table(
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
SELECT SELECT
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff, date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day') FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day')
@ -71,7 +71,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
SELECT SELECT
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff, date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day') FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
@ -89,7 +89,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
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 '5 days', now() - INTERVAL '5 days') FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
@ -106,7 +106,7 @@ CREATE TABLE tswtz_partitioned_table(
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
SELECT SELECT
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day') FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day')
@ -115,7 +115,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
SELECT SELECT
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day') FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
@ -124,7 +124,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
SELECT SELECT
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff, date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day') FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
@ -133,7 +133,7 @@ ROLLBACK;
BEGIN; BEGIN;
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day'); SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
SELECT SELECT
date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff, date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff,
date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days') FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')

View File

@ -4,4 +4,4 @@ test: multi_test_catalog_views
test: timeseries_create_drop_timeseries_table test: timeseries_create_drop_timeseries_table
test: timeseries_get_missing_partition_ranges test: timeseries_get_missing_partition_ranges
test: timeseries_create_missing_partitions test: timeseries_create_missing_partitions