I'm struggeling on the following problem using variables in an Oozie workflow definition checking if a specific file was created. It is working with absolute path like the following, but I cannot use an absolute path:
${fs:exists('/mypath/file.hql')}
In my case, the nameNode and the workflow id has to be replaced but in the decision node this is not working. The variables are not replaced, what is the correct syntax to do this?
<decision name="check-hql-file-created">
<switch>
<case to="hive-exec-il2rl-hql4baseentity">
${fs:exists(${nameNode}'/tmp/oozie_tmp/'${wf:id()}'.hql')}
</case>
<default to="il2rl-loop"/>
</switch>
</decision>
it is working with concatenation like the following:
<switch>
<case to="hive-exec-il2rl-hql4baseentity">
${fs:exists(concat(concat(concat(concat(concat(nameNode, '/tmp/oozie_tmp/'), wf:id()), '_'), replaceAll(asJson, "\\{\"|,.+$", "")), '.hql')) == "true"}
</case>
<default to="il2rl-loop"/>
</switch>
Say you plan to use variables 'X' and 'Y', in some format such as /tmp/X/Y (let's call this 'PATH'), then:
Define X, Y and 'PATH' as a variable like so
PATH = /tmp/${X}/${Y}/
Then use PATH as:
${fs:exists(PATH)}
this works.
However, if you want to run this workflow via coordinators, it is better to first assign each of those variables separately too. Like so:
Define X, Y and 'PATH' as a variable like so
X = value1
Y = value2
PATH = /tmp/${X}/${Y}/
Then use PATH as:
${fs:exists(PATH)}
and do exactly the same in your coordinator.
Note: value1 and value2 can be Oozie expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With