hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zheng Shao <>
Subject Re: Hive query questions: referring to aliased column in group by and comments
Date Fri, 23 Oct 2009 17:25:49 GMT
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


On Fri, Oct 23, 2009 at 8:12 AM, Ryan LeCompte <> 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)
> 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


View raw message