This is the third and last installment in the “Exporting Hive Data to HDFS” and “Exporting Hive Data to Local File System” series. And now we’ll discuss the remaining parameters, which were not addressed in the previous blogs but are required for exporting the data.
Look at the below example:
INSERT OVERWRITE LOCAL DIRECTORY ‘Desktop/Docs/deptdir’
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
ESCAPED BY ””
LINES TERMINATED BY ‘\n’
SELECT * FROM Dept_Test;
As stated in the previous post, the “Directory-Location” provides the storage location of the data, which can be either HDFS or a local file system. If the target directory exists, the INSERT OVERWRITE statement will overwrite it; otherwise, it will create the specified directory in the provided path. Within a map-reduce task, Hive can write to HDFS directories in parallel. DELIMITED or a desired SERDE should be used as the basis for the ROW FORMAT. The “FIELDS TERMINATED BY” clause specifies how the columns should be separated, whereas the “LINES TERMINATED BY” clause specifies how the lines should be terminated. STORED AS should be used to specify the file format in which the data should be saved. The data to be stored should be supplied in the “VALUES” section, or it might come from a specific table.
Hope this helps.
Please subscribe for more interesting updates.
It’s a shame you don’t have a donate button! I’d certainly donate to
this brilliant blog! I suppose for now i’ll settle
for bookmarking and adding your RSS feed to my Google
account. I look forward to fresh updates and will share this
blog with my Facebook group. Chat soon!
LikeLike
I spend a lot of time writing blog posts and frequently forget to express gratitude to my readers and followers. Your feedback is really valuable to me. Thanks a lot.
LikeLike