...
An error is thrown if the partition_spec for the table already exists. You can use IF NOT EXISTS to skip the error.
Recover partitions
Hive stores a list of partitions for each table in its metastore. If, however, new partitions are directly added to HDFS (say by using hadoop fs -put
command), the metastore (and hence Hive) will not be aware of these partitions unless the user runs ALTER TABLE table_name ADD PARTITION
commands on each of the newly added partitions.
However, users can run
Code Block |
---|
MSCK REPAIR TABLE table_name;
|
which will add metadata about partitions to the Hive metastore for partitions for which such metadata doesn't already exist. In other words, it will add any partitions that exist on HDFS but not in metastore to the metastore.
The equivalent command on Amazon Elastic MapReduce (EMR)'s version of Hive is
Code Block |
---|
ALTER TABLE table_name RECOVER PARTITIONS;
|
Drop Partitions
Code Block |
---|
ALTER TABLE table_name DROP [IF EXISTS] partition_spec, partition_spec,... |
...