There are two types of files: File A and File B. If condition of my pipeline checks if the given CSV file is empty or not (True when empty False when not empty)
In case where the file is not empty i would like to execute a particular pipeline depending on the file name that means: If File A is non empty then execute pipeline A. If File B is non empty then execute pipeline B. Is it somehow possible to add this kind of a filter inside the false part of If condition? Or any other way to achieve the mentioned goal?
Get File Name gets the file name of the file being processed, switch decides based on this file name which dataflow to execute and gives row count as an output (Default = File A). The If condition decides based on the row count if a file is empty or not.
Inside the if condition if the file is not empty, i would like to execute pipeline depending on the file name. Either Pipeline A or B and not both as showin in the picture.
CodePudding user response:
I reproduced the above and you can see currently, ADF does not support nested if also switch inside if.
So, I followed the below approach and got the desired result for one or more than 1 file.
First, I have used Get Meta activity for the files list.
Give the ChildItems output from Get Meta data to ForEach.
The first ForEach used for finding the list of non-empty files. Create an array variable for that.
Use lookup to find the number of rows and check empty or not in if.
If condition:
@equals(activity('Lookup1').output.count,0)
Inside False activities of if, use append for non-empty files.
Now, use this list in another ForEach with switch activity.
Inside this ForEach, use switch activity and give @item()
.
Give all the files as cases so that switch can execute the cases for the respective non-empty files.
Inside the cases give the respective Execute pipeline activity.