Here's the same wikidoc in its usual display mode: Variable Substitution<https://cwiki.apache.org/confluence/display/Hive/LanguageManual+VariableSubstitution> .
-- Lefty On Sun, Jan 5, 2014 at 11:06 PM, lxw <lxw1...@qq.com> wrote: > > maybe you can see: > > > https://cwiki.apache.org/confluence/plugins/viewsource/viewpagesrc.action?pageId=30754722 > > > ------------------ Original ------------------ > *From: * "yogesh dhari";<yogeshh...@gmail.com>; > *Date: * Fri, Jan 3, 2014 01:13 AM > *To: * "user"<user@hive.apache.org>; > *Subject: * working with HIVE VARIALBE: Pls suggest > > Hello Hive Champs, > I have a case statement, where I need to check the date passed through > parameter, > If date is 1st date of the month then keep it as it as > else > set the parameter date to 1st date of the month. > and then later opretation are being performed on that date into hive > quries, > I have wrote this Hive QL > *select case when as_of_dt = ${hivevar:as_of_dt} then > ${hivevar:as_of_dt} else date_sub(${hivevar:as_of_dt} , > (day(${hivevar:as_of_dt} )) -1 ) end as as_of_dt from TABLE group by > as_of_dt ;* > O/P of this query is, lets say = 2012-08-01 > > I want to store the value of this Query into a variable. > like > > MY_VARIABLE = (*select case when as_of_dt = ${hivevar:as_of_dt} then > ${hivevar:as_of_dt} else date_sub(${hivevar:as_of_dt} , > (day(${hivevar:as_of_dt} )) -1 ) end as as_of_dt from TABLE group by > as_of_dt; )* > > > > How to achieve that. > Pls suggest, > Thanks in advance >