cancel
Showing results for 
Search instead for 
Did you mean: 

Allow pipeline execution on the basis of expression result of previous snap

amit_trivedi
New Contributor

How can I allow a pipeline to continue execute/not execute on the basis of the result of expression value of previous snap.
For example: I wan to continue pipeline execution only if there are some records exists in the csv file which I read in previous snaps in the pipeline else not continue execution.
Similarly, I want to check records in a sql table and if count >0 then I want to continue execution else I want to exit.

5 REPLIES 5

bojanvelevski
Valued Contributor

I think the Filter snap will do the job. For your first use case, If you want to check if some of the fields has a specific value, you’ll need something similar to this:

$Record == 'Required Value'

If your requirement is to check if you have any records at all, you can either group the records in an array, and count its length, or use an Aggregate snap after the CSV Parser/SQL reading, select the COUNT Function and add a result field , than again use the Filter snap with the following expression:

$ResultField > 0

Hope this helps,
Regards,
Bojan

amit_trivedi
New Contributor

Thanks for the reply.
If I use aggregate snap, it will change the structure of my data. I just wanted to check if my file(to be loaded) has records then load the entire file else exit the pipeline.
Is there a way to count records in a csv(without using Aggregate snap) which I would use in a Router. If the value>0 then load the file else exit the pipeline.
Kindly suggest.

File Reader Snap gives a “content-length” field, which when 0 means an empty file. You can use a Binary Router Snap to route the empty and non-empty files. Alternatively the CSV Parser Snap has an option to Ignore Empty data, which when enabled stops the execution.

For SQL Table, the SQL Server Select snap has an option to Ignore empty result, which when enabled stops execution

amit_trivedi
New Contributor

Thanks.
The “content-length field” is not visible in the expressions in binary router snap.