----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/39425/#review104096 -----------------------------------------------------------
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java <https://reviews.apache.org/r/39425/#comment162320> The aliases should be added only in select that succeds the groupby. Otherwise other operators like having/winodwing could misuse the col alias. Ex: explain select key as c0, count(*) as c1, sum(c1) over() from t1 group by key, value having c1 like '%abc%' order by c0; With this patch it will let this query through which is obviously wrong. - John Pullokkaran On Oct. 18, 2015, 9:47 p.m., pengcheng xiong wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/39425/ > ----------------------------------------------------------- > > (Updated Oct. 18, 2015, 9:47 p.m.) > > > Review request for hive, Ashutosh Chauhan and John Pullokkaran. > > > Repository: hive-git > > > Description > ------- > > Hive CLI session: > {noformat} > hive> create table abc(foo int, bar string); > OK > Time taken: 0.633 seconds > hive> select foo as c0, count(*) as c1 from abc group by foo, bar having bar > like '%abc%' order by foo; > FAILED: SemanticException [Error 10004]: Line 1:93 Invalid table alias or > column reference 'foo': (possible column names are: c0, c1) > {noformat} > Without having clause, the query runs fine, example: > {code} > select foo as c0, count(*) as c1 from abc group by foo, bar order by foo; > {code} > > > Diffs > ----- > > ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java e13356c > ql/src/java/org/apache/hadoop/hive/ql/parse/QBParseInfo.java 14a7e9c > ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java 3262887 > ql/src/test/queries/clientnegative/alias_groupby_orderby.q PRE-CREATION > ql/src/test/queries/clientpositive/lineage3.q 70d4e57 > ql/src/test/results/clientnegative/alias_groupby_orderby.q.out PRE-CREATION > ql/src/test/results/clientpositive/lineage3.q.out ad965c8 > > Diff: https://reviews.apache.org/r/39425/diff/ > > > Testing > ------- > > > Thanks, > > pengcheng xiong > >
