diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java index 684dec3c25..34906cd089 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java @@ -1347,6 +1347,9 @@ private static void checkColumnName(String columnName) throws SemanticException ASTNode child = (ASTNode) ast.getChild(i); int directionCode = DirectionUtils.tokenToCode(child.getToken().getType()); child = (ASTNode) child.getChild(0); + if (child.getToken().getType() != HiveParser.TOK_NULLS_FIRST && directionCode == DirectionUtils.ASCENDING_CODE) { + throw new SemanticException("create/alter table: not supported NULLS LAST for ORDER BY in ASC order"); + } if (child.getToken().getType() != HiveParser.TOK_NULLS_LAST && directionCode == DirectionUtils.DESCENDING_CODE) { throw new SemanticException("create/alter table: not supported NULLS FIRST for ORDER BY in DESC order"); } diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g index caee02d2e3..d9ee40b42e 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g +++ ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g @@ -2471,9 +2471,7 @@ columnNameOrder @init { pushMsg("column name order", state); } @after { popMsg(state); } : identifier orderSpec=orderSpecification? nullSpec=nullOrdering? - -> {$orderSpec.tree == null && $nullSpec.tree == null && nullsLast()}? - ^(TOK_TABSORTCOLNAMEASC ^(TOK_NULLS_LAST identifier)) - -> {$orderSpec.tree == null && $nullSpec.tree == null && !nullsLast()}? + -> {$orderSpec.tree == null && $nullSpec.tree == null}? ^(TOK_TABSORTCOLNAMEASC ^(TOK_NULLS_FIRST identifier)) -> {$orderSpec.tree == null}? ^(TOK_TABSORTCOLNAMEASC ^($nullSpec identifier))