gpt4 book ai didi

hadoop - 有条件地加入 Hive

转载 作者:可可西里 更新时间:2023-11-01 14:18:44 25 4
gpt4 key购买 nike

我想在 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 [Error 10019]: Line 3:1 OR not supported in JOIN currently 'supp_id'

最佳答案

你可以用 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

关于hadoop - 有条件地加入 Hive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39326610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com