Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 08-31-2016 04:27 PM
I have a hive table that I want to export to a local .csv file.
I tried this approach:
<code>insert overwrite local directory '/my/local/file/path' row format delimited fields terminated by ',' select * from my_table;
This puts a series of .deflate files in /my/local/file/path, but I want plain ol' .csv files.
How do I accomplish this?
I tried making a copy of the source table that is not compressed and is 'stored as textfile', but the output is still the same.
Thanks.
Created 08-31-2016 04:48 PM
Have you tried setting the following:
set hive.exec.compress.output=false
Created 08-31-2016 04:44 PM
Note, this works well, but I'd still like to know how to utilize the method mentioned above:
hive -e 'set hive.cli.print.header=true; select * from my_table' | sed 's/[\t]/,/g' > /my/path/output_folder/output_file.csv
Created 08-31-2016 04:48 PM
Created 08-31-2016 05:15 PM
You should be able to get this done (as a tab separated) by doing the following:
hive -e 'use <database>; select * from <table>;' > /tmp/<file>.csv