Hitesh Shah created HIVE-4635:
---------------------------------

             Summary: Invalid query parsing when handling order by on an 
aliased column
                 Key: HIVE-4635
                 URL: https://issues.apache.org/jira/browse/HIVE-4635
             Project: Hive
          Issue Type: Bug
            Reporter: Hitesh Shah


Assuming simple table src1, src2:

create table src1 (key int, value string);
create table src2 (key int, value string);

Ordering by s2.key gives an error:

hive>SELECT s2.key, count(distinct s2.value) as cnt FROM src1 s1 join src2 s2 
on (s1.key = s2.key) GROUP BY s2.key ORDER BY s2.key;
FAILED: SemanticException [Error 10004]: Line 1:117 Invalid table alias or 
column reference 's2': (possible column names are: key, cnt)

Ordering by key allows the hive query to run. 

However, if I select both s1.key and s2.key:

hive> SELECT s1.key, s2.key, count(distinct s2.value) as cnt FROM src1 s1 join 
src2 s2 on (s1.key = s2.key) GROUP BY s2.key, s1.key ORDER BY s2.key; 
FAILED: SemanticException [Error 10004]: Line 1:133 Invalid table alias or 
column reference 's2': (possible column names are: key, cnt)

Ordering by key in the above scenario allows the job to run but there is no 
indication which column is actually being used to order the results. 


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to