Join 在HiveQL的“on”子句中使用case语句的条件联接
假设:要连接的tbl_A列中的值具有不同的长度:5和10。 待连接的tbl_B列中的值的长度较大,连接substr时,应根据tbl_A中值的长度应用。 因此,在使用HiveQL连接表时,我试图在“ON”子句中应用case语句,结果出现以下错误: 编译语句时出错:失败:SemanticException[错误10017]:第22行:3在联接“11”中遇到左别名和右别名 这是我的密码:Join 在HiveQL的“on”子句中使用case语句的条件联接,join,hiveql,hue,case-statement,Join,Hiveql,Hue,Case Statement,假设:要连接的tbl_A列中的值具有不同的长度:5和10。 待连接的tbl_B列中的值的长度较大,连接substr时,应根据tbl_A中值的长度应用。 因此,在使用HiveQL连接表时,我试图在“ON”子句中应用case语句,结果出现以下错误: 编译语句时出错:失败:SemanticException[错误10017]:第22行:3在联接“11”中遇到左别名和右别名 这是我的密码: select a.fullname, b.birthdate from mydb.tbl_A a left j
select
a.fullname, b.birthdate
from mydb.tbl_A a
left join mydb.tbl_B b
on a.fullname =
case when length(a.fullname) = 5 then substr(b.othername,1,5)
when length(a.fullname)= 9 then substr(b.othername, 8, 9) end
and a.birthdate = b.birthdate
我找不到这方面的太多信息。非常感谢你的帮助。多谢各位 JOIN当前有一些限制。
这里有一个变通办法
select a.fullname
,b.birthdate
from tbl_A a
left join tbl_B b
on a.fullname =
substr(b.othername,1,5)
and a.birthdate =
b.birthdate
where length(a.fullname) <> 9
or a.fullname is null
union all
select a.fullname
,b.birthdate
from tbl_A a
left join tbl_B b
on a.fullname =
substr(b.othername,8,9)
and a.birthdate =
b.birthdate
where length(a.fullname) = 9
JOIN目前有一些限制。
这里有一个变通办法
select a.fullname
,b.birthdate
from tbl_A a
left join tbl_B b
on a.fullname =
substr(b.othername,1,5)
and a.birthdate =
b.birthdate
where length(a.fullname) <> 9
or a.fullname is null
union all
select a.fullname
,b.birthdate
from tbl_A a
left join tbl_B b
on a.fullname =
substr(b.othername,8,9)
and a.birthdate =
b.birthdate
where length(a.fullname) = 9