[ 
https://issues.apache.org/jira/browse/HIVE-7693?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pengcheng Xiong updated HIVE-7693:
----------------------------------
    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}

The above queries run well with CBO on in Hive master. We tested other queries 
as can be seen in the attachment. The summary is (1) Hive does not allow alias 
in group by; (2) Hive does not allow alias in having. The problem will appear 
only when the first query is run with CBO off. However, CBO should be on as 
default. Thus, we mark it as won't fix.

  was:
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}


> Invalid column ref error in order by when using column alias in select clause 
> and using having
> ----------------------------------------------------------------------------------------------
>
>                 Key: HIVE-7693
>                 URL: https://issues.apache.org/jira/browse/HIVE-7693
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.13.0
>            Reporter: Deepesh Khandelwal
>            Assignee: Pengcheng Xiong
>         Attachments: HIVE-7693.01.patch, HIVE-7693.02.patch, 
> HIVE-7693.03.patch, HIVE-7693.04.patch, HIVE-7693.05.patch, 
> HIVE-7693.06.patch, HIVE-7693.07.patch, HIVE-7693.08.patch, testingResults.pdf
>
>
> 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}
> The above queries run well with CBO on in Hive master. We tested other 
> queries as can be seen in the attachment. The summary is (1) Hive does not 
> allow alias in group by; (2) Hive does not allow alias in having. The problem 
> will appear only when the first query is run with CBO off. However, CBO 
> should be on as default. Thus, we mark it as won't fix.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to