If the partition of our table is created very much, it is a very troublesome thing for us to load the data, and hive provides dynamic partitioning to solve this problem.
You can infer the name of the partition you want to create based on the query parameters, and the partition is static, which is called dynamic partitioning.
How do you get it?
First copy the table structure:
CREATE table applogs like applogsnew;
Then perform the insert:
INSERT Overwrite TABLE applogsnew PARTITION (create_time)
SELECT Applogid, Msgtype, ClientType, create_time from Applogs;
Error, we need to turn on dynamic partition support
Set hive.exec.dynamic.partition=true;
Set hive.exec.dynamic.partition.mode=nostrict;
Set hive.exec.max.dynamic.partitions.pernode=1000;
Execute again
INSERT Overwrite TABLE applogsnew PARTITION (create_time)
SELECT Applogid, Msgtype, ClientType, create_time from Applogs;
Note:
When creating the partition, it is best not to create too many partitions, if the partition is too large, the query is very slow, as in window Next folder under the file too much will be very inconvenient for our use.
So what is the number of partitions that hive can support, which can be obtained using the command set hive.exec.max.dynamic.partitions.
How to quickly copy a partitioned table (including data) in Hive