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;
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:
Hope you find this article helpful.
Please subscribe for more interesting updates.
2 comments