Earlier posts on this site addressed the most of the use cases for Hive Partitioning. There will always be some questions when it comes to implementation and new types of needs. In this post, we’ll go through how to replace existing partitioned data in HDFS subdirectories that have already been created.
Syntax for Static Partitioning:
LOAD DATA LOCAL INPATH ‘Location’
OVERWRITE INTO TABLE <TableName>
PARTITION (Partition_Specification);
Example:
LOAD DATA LOCAL INPATH ‘Desktop/Docs/UK_Cities.txt’
OVERWRITE INTO TABLE CitiesList
PARTITION (Country=’UK’);
Syntax for Dynamic Partitioning:
INSERT OVERWRITE INTO <TableName> PARTITION(Partioned_Column)
SELECT * FROM <SourceTable>;
Example:
INSERT OVERWRITE INTO TownsList_Dynamic PARTITION(Country)
SELECT * FROM TownsList;
I hope you found this post useful.
Please do subscribe for more interesting updates.
One comment