Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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