Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

CASE statement Error in Beeline HIVE

Solved Go to solution
Highlighted

CASE statement Error in Beeline HIVE

 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: CASE statement Error in Beeline HIVE

Hi @Gayathri Devi

sample nested case which can be used in hive.

Select case 
when hour(split(split(hbid,"#")[1],"_")[1])== 0 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","0-2") 
when hour(split(split(hbid,"#")[1],"_")[1]) ==1 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","0-2")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==2 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==2 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==3 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
else 'NA'
end as column1 from table_name; 

If it helps then please accept it as the best answer! Happy Hadooping!!

View solution in original post

3 REPLIES 3
Highlighted

Re: CASE statement Error in Beeline HIVE

@Gayathri Devi

You have missed end in the statement. This should work.

case when hour(split(split(hbid,"#")[1],"_")[1])==0<br>then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","0-2") else 'NA' end

Hope it helps!!

Re: CASE statement Error in Beeline HIVE

Hi @Gayathri Devi

sample nested case which can be used in hive.

Select case 
when hour(split(split(hbid,"#")[1],"_")[1])== 0 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","0-2") 
when hour(split(split(hbid,"#")[1],"_")[1]) ==1 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","0-2")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==2 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==2 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
when hour(split(split(hbid,"#")[1],"_")[1]) ==3 then concat(split(split(split(hbid,"#")[1],"_")[1]," ")[0],"/","2-4")]
else 'NA'
end as column1 from table_name; 

If it helps then please accept it as the best answer! Happy Hadooping!!

View solution in original post

Highlighted

Re: CASE statement Error in Beeline HIVE

Will Try and let u know. thanks a lot.

Don't have an account?
Coming from Hortonworks? Activate your account here