Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to get non-compressed .csv output from hive table

avatar
Super Collaborator

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.

1 ACCEPTED SOLUTION

avatar
Super Guru

@Zack Riesland

Have you tried setting the following:

set hive.exec.compress.output=false

View solution in original post

3 REPLIES 3

avatar
Super Collaborator

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

avatar
Super Guru

@Zack Riesland

Have you tried setting the following:

set hive.exec.compress.output=false

avatar

@Zack Riesland

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