Is it possible to add multiple partitions to a table in Apache Hive at the same time?
If you’re using version 0.7 or older, the answer is NO. One division should be added at a time.
The answer is YES if you’re running version 0.8 or later.
Tables are divided into partitions using Apache Hive. Partitioning divides a table into divisions based on the values of specific columns such as date (month, year,etc) , region, and sector.
ALTER TABLE ADD PARTITION is used to add partitions to a table. The partition values should only be quoted if they are strings. A directory holding data files must be the destination.
ALTER TABLE table_name
ADD [IF NOT EXISTS] PARTITION partition_spec [LOCATION ‘location’]
[, PARTITION partition_spec [LOCATION ‘location’], …];
ALTER TABLE tbPopulationData ADD
PARTITION (city=’San Antonio’, country=’us’) location ‘/path/to/us/sanantonio’
,PARTITION (city=’San Diego’, country=’us’) location ‘/path/to/us/sandiego’;
The above command will help in creating two new partitions to the table.
Hope you find this article helpful.
Subscribe to our mailing list to be notified of new articles.