Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive query output to file

Tags:

hadoop

hive

I run hive query by java code. Example:

"SELECT * FROM table WHERE id > 100"

How to export result to hdfs file.

like image 779
cldo Avatar asked Jan 12 '13 03:01

cldo


People also ask

How do you write a query output to a file in hive?

To directly save the file in HDFS, use the below command: hive> insert overwrite directory '/user/cloudera/Sample' row format delimited fields terminated by '\t' stored as textfile select * from table where id >100; This will put the contents in the folder /user/cloudera/Sample in HDFS. Show activity on this post.


1 Answers

The following query will insert the results directly into HDFS:

INSERT OVERWRITE DIRECTORY '/path/to/output/dir' SELECT * FROM table WHERE id > 100; 
like image 53
Charles Menguy Avatar answered Sep 20 '22 08:09

Charles Menguy