How to quickly copy a partitioned table (including data) in Hive

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.