我想在Hive中执行以下查询 -
select * from supp a inner join trd_acct b
on
(a.btch_id = 11170 AND a.btch_id = b.btch_id)
OR (a.btch_id = 11164 AND a.supp_id = b.supp_id)
但是得到错误 -
FAILED:SemanticException [错误10019]:第3行:1或不支持 JOIN目前'supp_id'
答案 0 :(得分:6)
您可以使用UNION
解决此问题:
select * from supp a inner join trd_acct b
on a.btch_id = 11170 AND a.btch_id = b.btch_id
UNION ALL
select * from supp a inner join trd_acct b
on a.btch_id = 11164 AND a.supp_id = b.supp_id
或者您可以尝试CASE EXPRESSION
:
select * from supp a
inner join trd_acct b
on CASE WHEN a.btch_id = 11164 THEN a.supp_id
WHEN a.btch_id = 11170 THEN a.btch_id END
= CASE WHEN a.btch_id = 11164 THEN b.supp_id
WHEN a.btch_id = 11170 then b.btch_id END
答案 1 :(得分:1)
以下查询在Hive(Hadoop)中正常工作 -
select * from supp a inner join trd_acct b
where
(a.btch_id = 11170 AND a.btch_id = b.btch_id)
OR (a.btch_id = 11164 AND a.supp_id = b.supp_id)
我已在Hive Console中测试过。