1) Hive does not support that yet. If you don't want to repeat the expression, there is one work-around with sub query:
SELECT myalias, count(1) FROM (SELECT if(col='x', 1, 0) as myalias) tmp GROUP BY myalias 2) Yes. Comment lines begin with "-- ". It's the standard SQL comment format. Zheng On Fri, Oct 23, 2009 at 8:12 AM, Ryan LeCompte <[email protected]> wrote: > Hey guys! > > Two questions: > > > 1) Is it possible to refer to an aliased column in the GROUP BY of a single > query? Hive is complaining if I try to do something like: > > SELECT if(col1='x',1,0) AS MYALIAS, count(1) > GROUP BY MYALIAS; > > It seems like I have to re-paste the whole if(...) in the GROUP BY for the > query to work. If I have fairly complicated expressions in the SELECT, it's > a bit tedious to copy/paste them again in the GROUP BY. Am I missing > something here? > > 2) Also, if I have a large query in a myquery.q file to feed into the hive > cli via the -f option, can I specify comments before query so that the hive > engine ignores them? Syntax? > > Thanks! > > Ryan > > -- Yours, Zheng
