In my oozie workflow I dynamically create a hive table, say T1. This hive action is then followed by a map-reduce action. I want to set number of reducers property (mapred.reduce.tasks) equal to distinct values of a field say (T1.group). Any ideas how to set value of some oozie parameter dynamically and how to get value of the parameter from hive distinct action to oozie parameter?
1 Answers
3
votes
I hope this can help:
- Create the hive table as you are doing already.
- Execute another Hive query which calculates the distinct values for the column and writes it to a file in hdfs.
- Create an
Shell
action, which will read the file and echo the value in the form ofkey=value
. Enable thecapture-output
for the shell action. - This is your MR action. Now access the action data using the Oozie EL functions. e.g.
${wf:actionData('ShellAction')['key']}
, pass this value to themapred.reduce.tasks
in theconfiguration
tag of the MR action.