Rename Partition
Function
Modify the partition value of a partition in an OBS partitioned table. This command only supports OBS tables and does not support managed tables.
Syntax
ALTER TABLE table_name PARTITION partition_specs RENAME TO PARTITION partition_specs;
Parameters
| Parameter | Description |
|---|---|
| table_name | Table name. |
| partition_specs | Partition specification, in the format (col1=val1, col2=val2, ...). The value before RENAME TO is the original partition value, and the value after is the new partition value. If the partitioned table has multiple partition columns, all partition column values must be specified. The order can be arbitrary. |
Precautions
- This command only supports OBS tables and does not support managed tables.
- The table and partition to be renamed must already exist. Otherwise, an error will occur. The new partition name must not duplicate any existing partition name. Otherwise, an error will occur.
- If the partitioned table is partitioned by multiple fields, all partition fields must be specified when renaming a partition. The order of the specified fields can be arbitrary.
- Parameters in partition_specs are enclosed in parentheses by default, for example: PARTITION (dt='2009-09-09', city='xxx').
Example 1: Rename a Single Partition Column
Rename the partition year=2023 to year=2024 in the table log_data.
ALTER TABLE log_data PARTITION (year='2023') RENAME TO PARTITION (year='2024');
Example 2: Rename Multiple Partition Columns
Rename the partition city='city1', dt='2023-01-01' to city='city2', dt='2023-06-01' in the table student.
ALTER TABLE student PARTITION (city='city1', dt='2023-01-01') RENAME TO PARTITION (city='city2', dt='2023-06-01');
Example 3: Rename a Date Partition
Rename the date partition dt='2023-12-31' to dt='2024-01-01' in the table sales.
ALTER TABLE sales PARTITION (dt='2023-12-31') RENAME TO PARTITION (dt='2024-01-01');
Example 4: Change Partition Value (Modify Only Some Partition Column Values)
Rename the partition region='east', type='click'` to `region='west', type='click' in the table event_log, modifying only the region column value.
ALTER TABLE event_log PARTITION (region='east', type='click') RENAME TO PARTITION (region='west', type='click');
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot