How to Update/Drop a Hive Partition?

2019-01-29 22:00发布

After adding a partition to an external table in Hive, how can I update/drop it?

标签: hive hiveql
2条回答
Evening l夕情丶
2楼-- · 2019-01-29 22:19

You can either copy files into the folder where external partition is located or use

INSERT OVERWRITE TABLE tablename1 PARTITION (partcol1=val1, partcol2=val2...)...

statement.

查看更多
聊天终结者
3楼-- · 2019-01-29 22:35

You can update a Hive partition by, for example:

ALTER TABLE logs PARTITION(year = 2012, month = 12, day = 18) 
SET LOCATION 'hdfs://user/darcy/logs/2012/12/18';

This command does not move the old data, nor does it delete the old data. It simply sets the partition to the new location.

To drop a partition, you can do

ALTER TABLE logs DROP IF EXISTS PARTITION(year = 2012, month = 12, day = 18);

Hope it helps!

查看更多
登录 后发表回答