How to create a shared tab file from a bush request?

I am trying to create a tab-separated value from a bush request.

Following the Apache Hive wiki, I wrote my query as:

INSERT OVERWRITE LOCAL DIRECTORY '/home/luca/query_results/'
ROW FORMAT DELIMITED 
FIELDS TERMINATED BY  '\t' ESCAPED BY '"' LINES TERMINATED BY '\n' 
STORED AS TEXTFILE
SELECT * FROM mytable ;

(note that the real request is quite complicated, I know that I could use it hive -e "Select * from mytable > outputin this simple case).

The query works, but in the query_results directory I find one file with the extension .snappy, and when I open it, it appears to be a binary file, not a text file.

What is wrong with my request? How can I get the results of my query in a well-formatted text file (I want to write a bush script that returns several such files. If I can even specify the file name from the hive, this will be a bonus).

+4
source share
2 answers

Adding a comment as an answer

The .snappy file problem can be solved by decompressing. Use the following:

      set hive.exec.compress.output=false

Once a compressed compressed file cannot be unpacked due to its encoded structure.

The above compression property can either be set permanently in the hive-site.xml file, or you can do it manually each time you run an insert request

+2
source

To open the .snappy extension, we need to use the text syntax in the request.

0
source

All Articles