Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export HIVE to a CSV

I have some data in HIVE, and I would like to see it in LibreOffice.

How do I export this data and later import it on Libreoffice

like image 959
oleber Avatar asked Aug 16 '12 13:08

oleber


People also ask

Does Hive support CSV?

You can easily import tasks from a CSV file into a Hive project. To begin, download a sample CSV by going to your profile dropdown, then Import tasks, and selecting Import CSV.

How do I save a Hive output to a text file?

To directly save the file in HDFS, use the below command: hive> insert overwrite directory '/user/cloudera/Sample' row format delimited fields terminated by '\t' stored as textfile select * from table where id >100; This will put the contents in the folder /user/cloudera/Sample in HDFS. Save this answer.


1 Answers

Based on https://issues.apache.org/jira/browse/HIVE-1603:

$ hive
hive> set hive.exec.compress.output=false;
hive> create table csv_dump ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' as
hive> select ...YOUR_SELECT_QUERY_HERE...;
$ hadoop dfs -cat /user/hive/warehouse/csv_dump/* > ~/csv_dump.csv
like image 57
user1486325 Avatar answered Nov 16 '22 02:11

user1486325