One Star

Left Join and tMap

Hi,
I have some questions about joins in the tMap component.
1/ If I use a left join (ie inner join is unchecked) between rowA and rowB, what does happen to the rowB structure when no rows matches the rowA ? Does rowB equals to null ? Or does rowB exists but with each of its field equal to null ?
2/ How can I test in the tMap if rowA did found a match or not ?
Thanks for your help.
4 REPLIES
Community Manager

Re: Left Join and tMap

Hello
1/ If I use a left join (ie inner join is unchecked) between rowA and rowB, what does happen to the rowB structure when no rows matches the rowA ? Does rowB equals to null ? Or does rowB exists but with each of its field equal to null ?

The columns from rowB will be null. see 1659.
2/ How can I test in the tMap if rowA did found a match or not ?

Link the output table to tLogRow which is used to display the result on console.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Left Join and tMap

Hi shong,
thanks for your reply.
So if rowA doesn't match rowB, all non nullable fields of rowB get default values ?
0 for integers, "" for Strings, 01/01/1970 for Dates and so on ?
That's really surprising...
So, how can I distinguish the case where rowB did match or not in the following case:
rowA (int id, String name)
0, Peter
1, John
2, Mark
rowB (int id, int amount)
1, 15
2, 10
After a left join I get: (id, name, amount)
0, Peter, 0
1, John, 15
2, Mark, 10
How do I know if Peter has an amount of 0 because it exists in rowB or if Peter doesn't exist in rowB ?
Employee

Re: Left Join and tMap

For the moment, it is necessary that at least one of your lookup's column be a nullable type.
Soon, a method call on the connection such as :
rowB.hasMatched()

will be possible.
There is an issue on this subject http://www.talendforge.org/bugs/view.php?id=1723
One Star

Re: Left Join and tMap

> For the moment, it is necessary that at least one of your lookup's column be a nullable type
Hi, even that is not a sufficient condition because the column could be null in the input data but ok, I will wait for the hasMatched() function.
Regards.