0
有没有人有关于此代码无法工作的想法?Hive中嵌套的Case语句
create table2 as
select
*,
1 as count,
case
when a=1 then
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
when tx in ("E_V","D_M","H_O","I_D") then "Other"
when tx="F_S" then "S"
when tx="G_L" then "L"
end
when b=1 then
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
end
else
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
when tx in ("D_M","E_V","F_S","H_O","I_D") then "Other"
when tx="G_L" then "L"
end
end as tx1
from table1
还是有更简单的方法来做到这一点?我正在写一个proc sql语句并将其推送到Hadoop(所以它需要与HiveQL兼容)。
你能分享你的日志结果吗?你怎么定义'不工作'? –
现在我手边没有'hive',但'count'别名是可疑的(可能是保留字),单引号比双引号安全,并且带有'*'的表别名(table1)。 *)值得尝试。 –
@RawFocus在SAS和Hue中,代码根本无法运行。这一切对你看起来都不错吗? – tzhang94