bashbigdataoozieoozie-workflow

Oozie variable cannot be resolved


Having an issue to pass a variable in decision Node. The parameter is declared under global config

 <global>
        <configuration>
            <property>
                <name>mapred.job.queue.name</name>
                <value>${yarnQueueName}</value>
            </property>
             <property>
                <name>currentDate</name>
                <value>${replaceAll(timestamp(), "T(\\d{2}):(\\d{2})Z", "")}</value>
            </property>
        </configuration>
    </global>

But when "currentDate" is used under Decision node, it fails to resolve.

<decision name="checkFile">
         <switch>
            <case to="an-email">
              ${fs:exists('/user/svc-pmdi/tmp/delta_Combination_'+currentDate+'.csv')}
            </case>
            <default to="end"/>
         </switch>
    </decision>

The error I am getting Error Code : EL_ERROR Error Message : variable [currentDate] cannot be resolved

My first oozie worflow..may be doing silly mistake. Please help me out .


Solution

  • You should not declare parameters for the workflow.xml in global configuration block. In your case you can make inline, moreover you have to change '+' to concat()

    <decision name="checkFile">
         <switch>
            <case to="an-email">
              ${fs:exists(concat(concat('/user/svc-pmdi/tmp/delta_Combination_', replaceAll(timestamp(), "T(\\d{2}):(\\d{2})Z", "")), '.csv'))}
            </case>
            <default to="end"/>
         </switch>
    </decision>
    

    You can create custom parameters to use them in the workflow.xml in block <parameters> in the beginning of workflow.xml. But only static strings can be stored there. Link to documentation: https://oozie.apache.org/docs/4.3.1/WorkflowFunctionalSpec.html#a4_Parameterization_of_Workflows