How can we count number of rows in Talend jobs

Brij picture Brij · Apr 25, 2014 · Viewed 12.5k times · Source

I have a scenario in which I only process my job only when i have numbers of rows greater then two. I used MySqlInput and tMap and tLog components in my job.

Answer

ydaetskcoR picture ydaetskcoR · Apr 25, 2014

You'll want a Run if connection between 2 components somewhere (they both have to be sub job startable - they should have a green square background when you drop them on to the canvas) and to use the NB_Line variable from the previous sub job component with something like this as your Run if condition (click the link and then click the component tab):

((Integer)globalMap.get("tMysqlInput_1_NB_LINE")) > 2

Be aware that the NB_Line functionality is only usable at the end of a sub job and can have "interesting" effects when using mid job but the Run if will end that first sub job and conditionally start the second one. If you are unable to find a way to break your job into 2 sub jobs then you can always use a tHash or a tBuffer output followed by an input and put the Run if link between the two.