Exporting Hive Table Data To Local System

This is a follow-up to the previous topic, “Exporting data from Hive to HDFS.” This time, though, we’ll learn how to export to a local file system.

The syntax is the same as in the last post, but it requires the addition of the term “LOCAL.” 

–Exporting data into HOME directory.
> INSERT OVERWRITE LOCAL DIRECTORY ‘/home/cloudera/testdatedir’
> ROW FORMAT DELIMITED
> STORED AS TEXTFILE
> SELECT * FROM testdate;

–Exporting data into local file system.
> INSERT OVERWRITE LOCAL DIRECTORY ‘Desktop/Docs/testdatedir’
> ROW FORMAT DELIMITED
> STORED AS TEXTFILE
> SELECT * FROM testdate;

This slideshow requires JavaScript.


Please note that if you forget specifying the keyword “LOCAL”, the path you specify will be regarded as a filename and stored in HDFS as a filename. Refer to the below screenshot:

MissingLOCAL_InsertOverwrite

Hope you find this article helpful.

Please subscribe for more interesting updates.

2 comments

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