...
The operation fails in the presence of an index.
Exchange partition is not allowed with transactional tables either as source or destination. Alternatively, use LOAD DATA or INSERT OVERWRITE commands to move partitions across transactional tables.
This command requires both the source and destination table names to have the same table schema.
If the schemas are different, the following exception is thrown:The tables have different schemas. Their partitions cannot be exchanged
...
Note that the schema for T1 is being used for the newly created partition T2(ds=1). Either all the partitions of T1 will get created or the whole operation will fail. All partitions of T1 are dropped.
Example Usage –
...
Partition
...
Spec With Multiple Partition Columns
Code Block | ||
---|---|---|
| ||
-- Create two tables with multiple partition columns. CREATE TABLE T1 (a int) PARTITIONED BY (d1 int, d2 int); CREATE TABLE T2 (a int) PARTITIONED BY (d1 int, d2 int); ALTER TABLE T1 ADD PARTITION (d1=1, d2=2); -- Alter the table, moving partition data d1=1, d2=2 from table T1 to table T2 ALTER TABLE T2 EXCHANGE PARTITION (d1 = 1, d2 = 2) WITH TABLE T1; |