[ https://issues.apache.org/jira/browse/HIVE-4564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stamatis Zampetakis updated HIVE-4564: -------------------------------------- I cleared the fixVersion field since this ticket is still open. Please review this ticket and if the fix is already committed to a specific version please set the version accordingly and mark the ticket as RESOLVED. According to the [JIRA guidelines|https://cwiki.apache.org/confluence/display/Hive/HowToContribute] the fixVersion should be set only when the issue is resolved/closed. > Distinct along with order by is not working when table name is part of column > name in order by clause > ----------------------------------------------------------------------------------------------------- > > Key: HIVE-4564 > URL: https://issues.apache.org/jira/browse/HIVE-4564 > Project: Hive > Issue Type: Bug > Components: Query Processor > Affects Versions: 0.9.0 > Reporter: chandra sekhar gunturi > Priority: Major > Labels: distinct, hive,, order > Fix For: 0.9.1 > > > I have following table named 'region'. > hive> desc region; > r_regionkey int > r_name string > r_comment string > When we use <distinct, orderby> clause combination in table_name.column_name > format, the query throws SemanticException. > For example, the following query throws error. > hive> select distinct region.r_name from region order by region.r_name; > FAILED: SemanticException [Error 10004]: Line 1:51 Invalid table alias or > column reference 'region': (possible column names are: _col0) > The same query works fine if the same query is used without table name in > order by clause. > The following query works fine for region table. > hive> select distinct region.r_name from region order by r_name; > This is a common scenario in actual real world scenarios. > For example, I want to find out what are all the cities my employees are from. > >> SELECT DISTINCT CITY.NAME FROM EMPLOYEE, CITY WHERE EMPLOYEE.CID=CITY.CID > >> ORDER BY CITY.NAME > Here we are forced to use CITY.NAME as it may conflict with EMPLOYEE.NAME. -- This message was sent by Atlassian Jira (v8.20.10#820010)