Import and Export Partitioned Data in Hive

Developers and analysts can take use of Apache Hive’s numerous built-in capabilities without putting in a lot of effort, and they won’t have to rely on third-party tools or write as many user-defined functions. Without leaving Hive’s interface, data can be imported and exported to HDFS, a local file system, or an RDBMS using a variety of methods. In this post, we’ll look how the partitioned data can be imported and exported in Hive.

Syntax / Example:
Export table employee
partition (emp_country=”in”, emp_state=”ka”) to ‘hdfs_exports_location/employee’;
The above command will export the partitioned data into the specified HDFS location, inside employee directory.

Import table employee
partition (emp_country=”us”, emp_state=”tn”) from ‘hdfs_exports_location/employee’;

Without more explanation, the syntax/example above explains it all. Please share your experiences if you’ve had any problems in importing or exporting.

Hope you find this article helpful.

Please subscribe for more interesting updates.

2 comments

  1. Note: : If there is a local or global prefixed index created on the partitioned table, import with PARTITION_OPTIONS=merge also converts the index to non-partitioned.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s