I am trying to join two DataFrame with condition.
I have two dataframe A and B.
A contains id,m_cd and c_cd columns B contains m_cd,c_cd and record columns
Conditions are -
- If m_cd is null then join c_cd of A with B
 - If m_cd is not null then join m_cd of A with B
 
we can use "when" and "otherwise()" in withcolumn() method of dataframe, so is there any way to do this for the case of join in dataframe.
I have already done this using Union.But wanted to know if there any other option available.