Manish Saraf Bhardwaj
Manish Saraf Bhardwaj

Reputation: 1058

In Oozie, how can I redirect the output of a query to a file?

In Oozie, I have used Hive action in Hue. and I want to redirect the output of the query to a file. How can I generate those file?

My HQL is : select * from emptable where day>=${fromdate} and day<=${todate}

My HiveServer Action contains: a. HQL script b. Two parameters options one for each dates like as fromdate = , todate = c. Added file hive-site.xml.

My question is how can I redirect the output of a query to a file

Upvotes: 0

Views: 1501

Answers (2)

Deb
Deb

Reputation: 471

Another Alternate option is by creating external Table in Hive, Example

CREATE EXTERNAL TABLE table_name(col type,col2 type) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' LOCATION '/path';

EXTERNAL table points to any HDFS location for its storage, rather than being stored in a folder specified by the configuration property hive.metastore.warehouse.dir

Upvotes: 0

Romain
Romain

Reputation: 7082

You would need to execute the Shell action which is not recommended, a better solution might be to do a

INSERT OVERWRITE DIRECTORY '/path' SELECT * FROM TABLE

Upvotes: 1

Related Questions