[resolved] How to test if tMap output has rows?

One Star

[resolved] How to test if tMap output has rows?

Hello,
I need a hand on this problem I got:
I have a tMap component, with two outputs:
1. the regular output table, returning a single record if the expression filter is met, and
2. the output reject table, returning a single record if the above expression filter is not met.
My goal is that, if the regular output HAS a row, then continue processing; that means that the output reject has NO records.
On the other hand, if the output reject has a record, which means the regular output has no records, I want to kill my job.
I do not manage to do this, because in either cases both actions are performed.
If I could test the number of rows of the tMap outputs, I could implement a "Run If" condition, but I do not know how to build the test.
Can anybody guide me how to do this?
I attach screenshots of the job, I am grateful for any suggestion.

Accepted Solutions
Community Manager

Re: [resolved] How to test if tMap output has rows?

Hello
On the other hand, if the output reject has a record, which means the regular output has no records, I want to kill my job.

Yes, you get the correct approach to reach your goal with runIf link and global vars. But why you link tJavaRow to tDie in your last image? I think you only need link the reject output to tDie and set the condition as: tLogRow_NB>0
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
One Star

Re: [resolved] How to test if tMap output has rows?

Hi again,
I finally managed to get the needed behavior from my job, I attach the screenshot, but I wonder:
is there any way to optimise it?

I suspect the answer is YES, and I am looking forward for your advice.
Thank you for helping a beginner to improve his style.
Furnica
Community Manager

Re: [resolved] How to test if tMap output has rows?

Hello
On the other hand, if the output reject has a record, which means the regular output has no records, I want to kill my job.

Yes, you get the correct approach to reach your goal with runIf link and global vars. But why you link tJavaRow to tDie in your last image? I think you only need link the reject output to tDie and set the condition as: tLogRow_NB>0
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How to test if tMap output has rows?

Thank you Shong, you are right.
Best regards,
Furnica
Five Stars

Re: [resolved] How to test if tMap output has rows?

Hello,

 

Can you please attach the screenshot of your solution. I am unable to see any screenshot in the original thread. 

 

Thanks much in advance.