Thursday, 11 October 2012

Talend-tmap left outer join and only get rows from left (main) table which does not exists in right table or how to do something like select * from where not exists(select...)



Problem - How to do left outer join in tmap and only get rows from left (main) table which does not exists in right table or how to do something like select * from where not exists(select...)

Solution - There are many - but one which we have used is given below
Say you have tables as below

Current_Snapshot -
name_skey
name_desc

Previous_Snapshot -
name_skey
name_desc

What we need is all rows from current_snapshot which does not exists in previous_snapshot
- Take main flow from current_snapshot - as main row input to Tmap
- in the input component of previous_snapshot select a dummy_flag with some constant value
example - select name_skey, name_desc, "XX" dummy_flag from previous_snapshot.
Now take flow from previous_snapshot  - as row lookup flow to above tmap.
In tmap - join this look up to main on name_skey and name_desc - use left outer join and all rows.
Now in output table in tmap - use expression and there put lookuprow.dummy_flag==null
What happens is that tmap will join all rows from current_snapshot to previous_snapshot and for those rows which exists in current_snapshot and not in previous_snapshot it will have dummy_flat==null and our expression filter in tmap helps us in identifying these row.





6 comments:

  1. This is exactly what I'm looking for! I would love to see a screenshot, but the screenshot above seems to be broken. Would you re-post it, please?

    ReplyDelete
  2. I see the screenshot now, and I think I have figured it out. (I also had to monkey with my join a bit.) Thank you for pointing me in the right direction!
    -- Brian

    ReplyDelete
  3. thanks for tutorials. I would love to see a screenshot, but the screenshot above seems to be broken. Would you re-post it, please?

    ReplyDelete
  4. Thanks for sharing INFO about JOINS in Talend technology. Keep Sharing

    ReplyDelete
  5. This LEFT OUTER JOIN tutorial is very helpful for database developers! The explanation of join operations is very clear. For tech learners in Electronic City, an AI ML course in Electronic City with placement can provide similar practical learning for career success. Thanks for sharing this helpful SQL guide!

    ReplyDelete