In Oozie, I have used Hive action in Hue, same action I used parameter options to supply date parameter. Here I want to provide dynamic date parameter such as yesterday date and day before yesterday. How can I generate those date? and how can I pass as parameter.
My HQL is :
CREATE TABLE IF NOT EXISTS tmp_table as
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 option for HQL script.
What I tried: I created two separate shell scripts which returns date. One of Shell script is
#! /bin/bash
FROM_DAY=$(date +%Y-%m-%d -d " - 1 day")
echo "$FROM_DAY"
and hive action parameter become fromdate = /user/manishs/Oozie/filter.sh
However this approach is not working and gives exceptions: Error: Error while compiling statement: FAILED: ParseException line 4:11 cannot recognize input near '/' 'user' '/' in expression specification (state=42000,code=40000)
NOTE:
If I pass a date as : fromdate ='2015-08-01' , it is working and give results.
My question is how can I pass a dynamic date in a hive server action as a parameter. OR Is any way to pass dynamic filter to a query.
try this,
filter.sh should be at given place
Oozie is a scheduler, right? So why not use the built-in EL functions to compute "today" and "yesterday" and pass them to the Hive action?
In the Coordinator script, assuming that you are using Los Angeles time zone, it should look like...
Then in the Workflow script, use the
<param>
element to pass the properties to Hive.Reference: Oozie Coordinator documentation
OK, probably you can't do that with Hue. But the Hue editor has so many limitations that you can't do much with it anyway.