[ https://issues.apache.org/jira/browse/HIVE-27649?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ayush Saxena updated HIVE-27649: -------------------------------- Summary: Support ORDER BY clause in subqueries with set operators (was: Subqueries with a set operator do not support order by clauses) > Support ORDER BY clause in subqueries with set operators > -------------------------------------------------------- > > Key: HIVE-27649 > URL: https://issues.apache.org/jira/browse/HIVE-27649 > Project: Hive > Issue Type: Bug > Components: Parser > Affects Versions: 3.1.2, 4.0.0 > Reporter: Nicolas Richard > Assignee: Nicolas Richard > Priority: Major > Labels: pull-request-available > > Consider the following query: > {code:java} > select key from ((select key from src order by key) union (select key from > src))subq {code} > Up until 3.1.2, Hive would parse this query without any problems. However, if > you try it on the latest versions, you'll get the following exception: > {code:java} > org.apache.hadoop.hive.ql.parse.ParseException: line 1:60 cannot recognize > input near 'union' '(' 'select' in subquery source > at > org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:125) > at > org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:97) {code} > With the inner exception stack trace being: > {code:java} > NoViableAltException(367@[]) > at > org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.identifier(HiveParser_IdentifiersParser.java:14006) > at > org.apache.hadoop.hive.ql.parse.HiveParser.identifier(HiveParser.java:45086) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.subQuerySource(HiveParser_FromClauseParser.java:5411) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.atomjoinSource(HiveParser_FromClauseParser.java:1921) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.joinSource(HiveParser_FromClauseParser.java:2175) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.atomjoinSource(HiveParser_FromClauseParser.java:2110) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.joinSource(HiveParser_FromClauseParser.java:2175) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.fromSource(HiveParser_FromClauseParser.java:1750) > at > org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.fromClause(HiveParser_FromClauseParser.java:1593) > at > org.apache.hadoop.hive.ql.parse.HiveParser.fromClause(HiveParser.java:45094) > at > org.apache.hadoop.hive.ql.parse.HiveParser.atomSelectStatement(HiveParser.java:38538) > at > org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:38831) > at > org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:38424) > at > org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:37686) > at > org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:37574) > at > org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:2757) > at > org.apache.hadoop.hive.ql.parse.HiveParser.explainStatement(HiveParser.java:1751) > at > org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1614) > at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:123) > at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:97) > {code} > Note that this behavior also happens if the subquery contains a SORT BY, > CLUSTER BY, DISTRIBUTE BY or LIMIT clause. > -- This message was sent by Atlassian Jira (v8.20.10#820010)