diff --git a/tests/queries/0_stateless/01818_move_partition_simple.reference b/tests/queries/0_stateless/01818_move_partition_simple.reference new file mode 100644 index 00000000000..d5aea68e9f9 --- /dev/null +++ b/tests/queries/0_stateless/01818_move_partition_simple.reference @@ -0,0 +1,12 @@ +INSERT INTO main_table_01818 +INSERT INTO tmp_table_01818 +INSERT INTO tmp_table_01818 +ALL tmp_table_01818 200 +ALL main_table_01818 100 +tmp_table_01818 100 +main_table_01818 100 +Executing ALTER TABLE MOVE PARTITION... +ALL tmp_table_01818 100 +ALL main_table_01818 200 +tmp_table_01818 0 +main_table_01818 200 diff --git a/tests/queries/0_stateless/01818_move_partition_simple.sql b/tests/queries/0_stateless/01818_move_partition_simple.sql new file mode 100644 index 00000000000..6ca3ae75efc --- /dev/null +++ b/tests/queries/0_stateless/01818_move_partition_simple.sql @@ -0,0 +1,122 @@ +DROP TABLE IF EXISTS main_table_01818; +DROP TABLE IF EXISTS tmp_table_01818; + + +CREATE TABLE main_table_01818 +( + `id` UInt32, + `advertiser_id` String, + `campaign_id` String, + `name` String, + `budget` Float64, + `budget_mode` String, + `landing_type` String, + `status` String, + `modify_time` String, + `campaign_type` String, + `campaign_create_time` DateTime, + `campaign_modify_time` DateTime, + `create_time` DateTime, + `update_time` DateTime +) +ENGINE = MergeTree +PARTITION BY advertiser_id +ORDER BY campaign_id +SETTINGS index_granularity = 8192; + +CREATE TABLE tmp_table_01818 +( + `id` UInt32, + `advertiser_id` String, + `campaign_id` String, + `name` String, + `budget` Float64, + `budget_mode` String, + `landing_type` String, + `status` String, + `modify_time` String, + `campaign_type` String, + `campaign_create_time` DateTime, + `campaign_modify_time` DateTime, + `create_time` DateTime, + `update_time` DateTime +) +ENGINE = MergeTree +PARTITION BY advertiser_id +ORDER BY campaign_id +SETTINGS index_granularity = 8192; + +SELECT 'INSERT INTO main_table_01818'; +INSERT INTO main_table_01818 SELECT 1 as `id`, 'ClickHouse' as `advertiser_id`, * EXCEPT (`id`, `advertiser_id`) +FROM generateRandom( + '`id` UInt32, + `advertiser_id` String, + `campaign_id` String, + `name` String, + `budget` Float64, + `budget_mode` String, + `landing_type` String, + `status` String, + `modify_time` String, + `campaign_type` String, + `campaign_create_time` DateTime, + `campaign_modify_time` DateTime, + `create_time` DateTime, + `update_time` DateTime', 10, 10, 10) +LIMIT 100; + +SELECT 'INSERT INTO tmp_table_01818'; +INSERT INTO tmp_table_01818 SELECT 2 as `id`, 'Database' as `advertiser_id`, * EXCEPT (`id`, `advertiser_id`) +FROM generateRandom( + '`id` UInt32, + `advertiser_id` String, + `campaign_id` String, + `name` String, + `budget` Float64, + `budget_mode` String, + `landing_type` String, + `status` String, + `modify_time` String, + `campaign_type` String, + `campaign_create_time` DateTime, + `campaign_modify_time` DateTime, + `create_time` DateTime, + `update_time` DateTime', 10, 10, 10) +LIMIT 100; + +SELECT 'INSERT INTO tmp_table_01818'; +INSERT INTO tmp_table_01818 SELECT 3 as `id`, 'ClickHouse' as `advertiser_id`, * EXCEPT (`id`, `advertiser_id`) +FROM generateRandom( + '`id` UInt32, + `advertiser_id` String, + `campaign_id` String, + `name` String, + `budget` Float64, + `budget_mode` String, + `landing_type` String, + `status` String, + `modify_time` String, + `campaign_type` String, + `campaign_create_time` DateTime, + `campaign_modify_time` DateTime, + `create_time` DateTime, + `update_time` DateTime', 10, 10, 10) +LIMIT 100; + +SELECT 'ALL tmp_table_01818', count() FROM tmp_table_01818; +SELECT 'ALL main_table_01818', count() FROM main_table_01818; +SELECT 'tmp_table_01818', count() FROM tmp_table_01818 WHERE `advertiser_id` = 'ClickHouse'; +SELECT 'main_table_01818', count() FROM main_table_01818 WHERE `advertiser_id` = 'ClickHouse'; + +SELECT 'Executing ALTER TABLE MOVE PARTITION...'; +ALTER TABLE tmp_table_01818 MOVE PARTITION 'ClickHouse' TO TABLE main_table_01818; + + +SELECT 'ALL tmp_table_01818', count() FROM tmp_table_01818; +SELECT 'ALL main_table_01818', count() FROM main_table_01818; +SELECT 'tmp_table_01818', count() FROM tmp_table_01818 WHERE `advertiser_id` = 'ClickHouse'; +SELECT 'main_table_01818', count() FROM main_table_01818 WHERE `advertiser_id` = 'ClickHouse'; + + +DROP TABLE IF EXISTS main_table_01818; +DROP TABLE IF EXISTS tmp_table_01818;