Reply
Explorer
Posts: 21
Registered: ‎05-18-2017

how to download hive data into csv format

I have created tables in hive, now i would like to download those tables in csv format,  i have searched online, so i got these below solutions, but i dont understand how to use these commands on cloudera.
1.
hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /home/lvermeer/temp.csv
 
2.
set hive.io.output.fileformat = CSVTextFile;

INSERT OVERWRITE LOCAL DIRECTORY 'dir_path' SELECT FIELD1, FIELD2, FIELD3 FROM TABLE1;

If anyone knows, kindly help me out.

Thanks in advance.
Highlighted
Champion
Posts: 595
Registered: ‎05-16-2016

Re: how to download hive data into csv format

if you have hive shell or beeline - you can excute the same code nothing different 

or you can try hue web ui to export the hive results as .csv 

althought hue is not that good in downloading big tables . 

New Contributor
Posts: 12
Registered: ‎09-09-2017

Re: how to download hive data into csv format

You can try this as well in Unix. 

 

beeline - u 'your jdbc connection string' - - outputformat=csv2 -e "your query here" > output.csv

 

Let me know if it helps.

 

Thanks,

Manu

Announcements