0

I built a workflow that has two hive2 actions and I am running it using Hue. I need to get the current time from the system when the workflow starts and pass it to both actions. This is the structure of the workflow:

<?xml version="1.0" encoding="UTF-8"?>

<workflow-app xmlns="uri:oozie:workflow:0.5" name="workflow.xml">
    <global>
        <job-tracker>host1:1234</job-tracker>
        <name-node>hdfs://myhost:4312</name-node>
        <configuration> 
            <property> 
                <name>execution_start</name> 
                <value>${timestamp()}</value> 
            </property> 
        </configuration> 
    </global>
    <start to="script1" />
    <action name="script1">
        <hive2 xmlns="uri:oozie:hive2-action:0.2">
            <jdbc-url>jdbc:hive2://myhost:10/default</jdbc-url>
            <script>script1.hql</script>
            <param>execution_start=${execution_start}</param>
        </hive2>
        <ok to="script2" />
        <error to="fail" />
    </action>
    <action name="script2">
        <hive2 xmlns="uri:oozie:hive2-action:0.2">
            <jdbc-url>jdbc:hive2://myhost:10/default</jdbc-url>
            <script>script2.hql</script>
            <param>execution_start=${execution_start}</param>
        </hive2>
        <ok to="end" />
        <error to="fail" />
    </action>
    <kill name="fail">
        <message>Sub workflow failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end" />
</workflow-app>

I need to have the same timestamp in both hive actions. So far Hue asks to input the parameter with name execution_start.

I also tried: <param>execution_start=${wf:conf('execution_start')}>. I'm not prompted to input the parameter with this but I get a NULL value inside the script.

Notice that <param>execution_start=${timestamp()}> works, but it doesn't do the job for me as the timestamps would be different in each action.

nessa.gp
  • 1,804
  • 21
  • 20
  • 1
    See my answer to https://stackoverflow.com/questions/38337362/oozie-properties-defined-in-file-referenced-in-global-job-xml-not-visible-in-wo about `` not applying to all action types... And not being the place to define "parameters"... Which cannot be initialized from EL expressions anyway. – Samson Scharfrichter May 23 '18 at 19:53
  • I saw many answers but not yours, thanks for the insides. I know it doesn't work and why but I'm still looking for a solution. Writing the code was a simple way to explain what I would like to achieve. – nessa.gp May 24 '18 at 07:48
  • If the Workflow was scheduled by a Coordinator, you could use the "Workflow theoretical start time", cf. https://stackoverflow.com/questions/35047044/oozie-workflow-el-function-timestamp-does-not-give-seconds – Samson Scharfrichter May 24 '18 at 09:09

1 Answers1

1

You can invoke first an Oozie Shell action that just returns a timestamp, capture the output from this first action, and pass it to Hive2 actions using <param>execution_start=${wf:actionData('TimestampShell')}</param>

Harold
  • 455
  • 4
  • 10