I am running a query in Hive, which is like below, and have OR condition in the left join. When I run the select, it throws me couple of error messages.
OR not supported currently in JOIN ( got to know OR works only for equi joins in Hive)
Both left and right aliases encountered in JOIN 'cre_timestamp'
a.line_id,
a.seller,
a.sellerid,
a.sellername,
a.item_no,
a.item_cd,
a.cre_timestamp
from Table A
left join Table B
on translate(a.id,'0','') = translate(b.id,'0','')
or translate(a.seller,'Z','') = translate(b.seller,'Z','')
or (a.item_no=b.item_no and a.item_no is not null and a.item_cd is not null and a.item_no <> '' and a.item_cd <> '')
left join ( select id, line_id,cre_timestamp from table x) C
on a.id=c.id
and a.cre_timestamp < c.cre_timestamp
and a.cre_timestamp > date_sub(c.cre_timestamp,21)
and translate(a.id,'0','') = translate(b.id,'0','') or a.item_cd = b.item_cd
where a.seller is null
How can we overcome this issue?
#For 1: One way, I can try to write the query is, using a UNION, copy past the query 3 times, for the OR conditions.
#For 2:
If I cut the
and a.cre_timestamp < c.cre_timestamp
and a.cre_timestamp > date_sub(c.cre_timestamp,21)
and bring it into the where
clause at the bottom, it works fine. (want to understand why it doesn't work in a join)
On a whole, looking for a better approach, which will not affect the run-time and more optimized query, as if I change it to use a UNION, it has to process the same query 3 times which will affect the query.
Thank you for taking time to look into this.