Hive drops all the partitions if the partition col

2019-09-08 13:27发布

问题:

I am facing a strange issue with hive, I have a table, partitioned on the basis of dept_key (its a integer eg.3212) table is created as follows

create external table dept_details (dept_key,dept_name,dept_location) PARTITIONED BY (dept_key_partition INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '~' LOCATION '/dept_details/dept/';

Now I have some partitions already added e.g: 1204,1203,1204 When I tried dropping the partition I by mistake typed only dept_key and not "dept_key_partition" this in turn dropped all my partition drop query alter table dept_details drop partition (dept_key=12), its a very strange issue which I am facing. Please let me know what can be the probable issue. Thank you.

回答1:

From Hive LanguageManual DDL...

As of Hive 0.14 (HIVE-8411), users are able to provide a partial partition spec for certain above alter column statements, similar to dynamic partitioning (...) you can change many existing partitions at once using a single ALTER statement (...) Similar to dynamic partitioning, hive.exec.dynamic.partition must be set to true

Looks like the partial specification feature has been ported to other commands like DROP, TRUNCATE even if it's not explicit in the documentation.

In short: it's not a bug, it's a feature.