Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: link to Exchange Partition section in DDL doc

...

It is proposed as part of https://issues.apache.org/jira/browse/HIVE-4095. Once this is implemented, it should be part of the Language Manual DDL.
The idea is similar to this.

The high level idea is as follows:

Code Block

alter table <tablename> exchange partition (<(partial)?partition spec>) with table <tablename>

The semantics of the above statement is that the data is moved from the target table to the source table. Both the tables should have the same schema. The operation fails in the presence of an index. The source table should not have that partition. Consider the following examples:

Code Block

create table T1(a string, b string) partitioned by (ds string);
create table T2(a string, b string);

...

moves the data from T2 to T1@ds=1. The operation fails if T1@ds=1 already exists or T1 and T2 have different schemas. Note that the schema for T2 is being used for the newly created partition T1@ds=1.

Code Block

create table T1(a string, b string) partitioned by (ds string, hr string);
create table T2(a string, b string) partitioned by (hr string);

...