Hive query output to file

cldo picture cldo · Jan 12, 2013 · Viewed 151.9k times · Source

I run hive query by java code. Example:

"SELECT * FROM table WHERE id > 100"

How to export result to hdfs file.

Answer

Charles Menguy picture Charles Menguy · Jan 12, 2013

The following query will insert the results directly into HDFS:

INSERT OVERWRITE DIRECTORY '/path/to/output/dir' SELECT * FROM table WHERE id > 100;