How to detect "No Rows"

How to detect "No Rows"

I am using the "tMap" component to join together several hash tables.
How can I detect that the join of the hash tables has resulted in "no rows?"
I would like to generate an e-mail when this happens.
Thanks
Peter
Community Manager

Re: How to detect "No Rows"

Hi Peter
Link the output table from tMap to a tJavaFlex component, and use runIf connector to trigger the email component if the result of join is 0. For example:
....tMap--main--tJavaFlex
|
runIf
|
tSendMail
in the begin part of tJavaFlex, define a counter.
int nb_line=0;
in the main part of tJavaFlex, the counter will +1 if there comes an input row.
nb_line++;
in the end part of tJavaFlex, check the number of the counter if it is great than 0 or not, and store the result to a global variable for used later.
if(nb_line==0){
globalMap.put("isNoRow",true);
}else{
globalMap.put("isNoRow",false);
}
Set the condition of runIf with the global varaible,
(Boolean)globalMap.get('isNoRow")
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: How to detect "No Rows"

Hi Peter,
- I have one more small Idea, Use a context variable as cnt and set its default value to 0.
- Use simple tjavarow at the output for that join and put following code
context.cnt = context.cnt +1;
Connect tSendMail component from tjavarow with condition RunIf having condition context.cnt == 0;

Check sample screenshot, you will get an idea for this.
Vaibhav

Re: How to detect "No Rows"

Thanks for the ideas guys. I will try both.
Thanks!!!
Peter

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch