[ How to use Regular expression in OOZIE? ]
I want to check the file exist or not in the given HDFS location.
We can check the file exist or not in given HDFS location with the help of fs:exists i.e.
If file name is test_25082016
with the help of coordination job we can get date value i.e. as a parameter today
in our example.
job.prop
path=/user/cloudera/file/input/test_
in workflow.xml
<decision name="CheckFile">
<switch>
<case to="nextOozieTask">
${fs:exists(concat(concat(nameNode, path),today))}
</case>
<case to="nextOozieTask1">
${fs:exists(concat(concat(nameNode, path),yesterday))}
</case>
<default to="MailActionFileMissing" />
</switch> </decision>
it is working as expected.
But in my case i have files names in my HDFS location like below.
Example: test_25082016_08.10.06.681.csv ,test_24082016_08.13.16.681.csv
how to check this types file name i.e. after date values i.e._08.10.06.681.csv
,_08.13.16.681.csv
...etc.
Is it possible to use regular expression in oozie workflow, to check those values i.e _08.10.06.681.csv
how to validate in this case file is exist or not through oozie?
please help me on this thanks in advance.
Answer 1
In this case we can check whether the file is exist are not by using below code
<decision name="CheckFile">
<switch>
<case to="nextOozieTask">
${fs:exists(concat(concat(concat(concat(nameNode, path),today),'*"),'.csv'))}
</case>
<case to="nextOozieTask1">
${fs:exists(concat(concat(nameNode, path),yesterday))}
</case>
<default to="MailActionFileMissing" />
</switch> </decision>