HIVE 移动数据 (从表到分区表,分区表到子分区表)

Exchange Partition

Skip to end of metadata

Go to start of metadata

  • Exchange Partition

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:

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:

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

create table T2(a string, b string);

The operation

alter table T1 exchange partition (ds='1') with table T2

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.

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

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

The operation

alter table T1 exchange partition (ds='1') with table T2

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. Either all the partitions of T1 will get created or the whole operation will fail. All partitions of T2 are dropped.

转载于:https://my.oschina.net/repine/blog/541096

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值