本文介绍了从配置单元表中删除所有分区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何删除当前在Hive表中加载的所有分区?
How can I drop all partitions currently loaded in a Hive table?
我可以使用alter table <table> drop partition(a=, b=...);
我可以使用"recovery partitions"语句加载所有个分区.但是我似乎无法删除所有分区.
I can load all partitions with the recover partitions statement. But I cannot seem to drop all partitions.
我正在使用EMR 0.8.1.支持的最新Hive版本.
I'm using the latest Hive version supported by EMR, 0.8.1.
推荐答案
从0.9.0版开始,您可以使用比较器,可用于一次删除所有分区.
As of version 0.9.0 you can use comparators in the drop partition statement which may be used to drop all partitions at once.
一个例子,取自 drop_partitions_filter.q 测试用例:
An example, taken from the drop_partitions_filter.q testcase :
create table ptestfilter (a string, b int) partitioned by (c string, d string);
alter table ptestfilter add partition (c='US', d=1);
alter table ptestfilter add partition (c='US', d=2);
alter table ptestFilter add partition (c='Uganda', d=2);
alter table ptestfilter add partition (c='Germany', d=2);
alter table ptestfilter add partition (c='Canada', d=3);
alter table ptestfilter add partition (c='Russia', d=3);
alter table ptestfilter add partition (c='Greece', d=2);
alter table ptestfilter add partition (c='India', d=3);
alter table ptestfilter add partition (c='France', d=4);
show partitions ptestfilter;
alter table ptestfilter drop partition (c>'0', d>'0');
show partitions ptestfilter;
这篇关于从配置单元表中删除所有分区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!