I am trying to perform IF
[spark's coalesce] on top of a left outer joined output, but seems that NULL
is not getting handled as expected. Here are my base tables, sample query, output and expected output-
Base tables:
t1:
a,100
b,101
c,102t2:
101
Query:
select a.x, a.x1, IF(b.x1 is NULL,a.x1,b.x1) from t1 a LEFT OUTER JOIN t2 b on a.x1=b.x1;
Output:
a,100,null
b,101,101
c,102,null
Expected:
a,100,100
b,101,101
c,102,102
I have also tried wrapping the above query and then performing an IF on top of it. But with no success. Please suggest is I am missing something.