0

I want to check whether a file with a specific name exists or not in the given HDFS location. My file name is something like this: TEST_20190930.csv

I did some searches on the internet, found that fs:exists can help us to check this.

I want to check in my coordinator oozie if the file exists with the mentioned name (Test_20190930) where 20190903 is a date of receiving the file on the HDFS.

mkrieger1
  • 14,486
  • 4
  • 43
  • 54
HamidOvic
  • 93
  • 1
  • 2
  • 5

1 Answers1

0

You can use a unix script to check the file pattern as it provides more flexibility and options and call this script in oozie workflow

workflow can be something like that

<shell>
<exec> script.sh </exec>
</shell>
    <ok to="[NODE-NAME]"/>
    <error to="[NODE-NAME]"/>

while script.sh can be

 if hdfs dfs -test -e $HDFS_PATH; then
    echo "[$HDFS_PATH] exists on HDFS"
    hdfs dfs -ls $HDFS_PATH
exit 0
    else
echo "File not Found"
exit 1
fi
Strick
  • 1,228
  • 7
  • 15