I am just trying to understand the concept behind joining of 2 tables with an OR condition. My requirement is: I need to join 2 tables Table1 [colA, colB] and Table2 [colX, colY] on columns Table1.colA = Table2.colB but if colA is NULL the condition should be Table1.colB = Table2.colY.
Do I need to do join them separately and then do union? Or is there a way I can do it in one join? Note that I have millions of records in both tables and its a left join and the tables reside in HIVE. I don't have a reproducible example, just trying to understand the concept.
on case when IsNull(colA) then colB else colA end = case when IsNull(colA) then colY else colX end
this may cause performance issues though since like you said, you have millions of records. – wbrugato