@@ -37,14 +37,24 @@ ORDER BY (column1, column2, column3)
3737
38384 . Copy data from ` example_table_old ` into ` example_table_temp `
3939
40- a. Use this query to generate a list of INSERT statements
40+ a. Use this query to generate a list of INSERT statements
4141 ``` sql
42+ -- old Clickhouse versions before a support of `where _partition_id`
4243 select concat(' insert into example_table_temp select * from example_table_old where toYYYYMM(date)=' ,partition) as cmd,
4344 database, table, partition, sum (rows), sum (bytes_on_disk), count ()
4445 from system .parts
4546 where database= ' default' and table= ' example_table_old'
4647 group by database, table, partition
4748 order by partition
49+
50+ -- newer Clickhouse versions with a support of `where _partition_id`
51+ select concat(' insert into example_table_temp select * from ' , table,' where _partition_id = \' ' ,partition_id, ' \' ;' ) as cmd,
52+ database, table, partition, sum (rows), sum (bytes_on_disk), count ()
53+ from system .parts
54+ where database= ' default' and table= ' example_table_old'
55+ group by database, table, partition_id, partition
56+ order by partition_id
57+
4858 ```
4959
5060 b. Create an intermediate table
@@ -70,7 +80,7 @@ ORDER BY (column1, column2, column3)
7080 order by partition
7181 ` ` `
7282
73- 5 . Attach data from the intermediate table to ` example_table`
83+ 6 . Attach data from the intermediate table to ` example_table`
7484
7585 a. Use this query to generate a list of ATTACH statements
7686 ` ` ` sql
@@ -93,5 +103,5 @@ ORDER BY (column1, column2, column3)
93103 order by partition
94104 ` ` `
95105
96- 6 . Drop ` example_table_old` and ` example_table_temp`
106+ 7 . Drop ` example_table_old` and ` example_table_temp`
97107
0 commit comments