Index: ql/src/test/results/clientnegative/union.q.out =================================================================== --- ql/src/test/results/clientnegative/union.q.out (revision 0) +++ ql/src/test/results/clientnegative/union.q.out (revision 0) @@ -0,0 +1 @@ +FAILED: Error in semantic analysis: line 2:45 Top level Union is not supported currently; use a subquery for the union value Index: ql/src/test/queries/clientnegative/union.q =================================================================== --- ql/src/test/queries/clientnegative/union.q (revision 0) +++ ql/src/test/queries/clientnegative/union.q (revision 0) @@ -0,0 +1,4 @@ +explain +select s1.key as key, s1.value as value from src s1 + UNION ALL +select s2.key as key, s2.value as value from src s2; Index: ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (revision 724471) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (working copy) @@ -65,6 +65,7 @@ TABLE_ALIAS_NOT_ALLOWED("Table Alias not Allowed in Sampling Clause"), CLUSTERBY_DISTRIBUTEBY_CONFLICT("Cannot have both Cluster By and Distribute By Clauses"), CLUSTERBY_SORTBY_CONFLICT("Cannot have both Cluster By and Sort By Clauses"), + UNION_NOTIN_SUBQ("Top level Union is not supported currently; use a subquery for the union"), NON_BUCKETED_TABLE("Sampling Expression Needed for Non-Bucketed Table"); private String mesg; Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 724471) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -409,6 +409,13 @@ qbp.setDestLimit(ctx_1.dest, new Integer(ast.getChild(0).getText())); } break; + + case HiveParser.TOK_UNION: + // currently, we dont support subq1 union subq2 - the user has to explicitly say: + // select * from (subq1 union subq2) subqalias + if (!qbp.getIsSubQ()) + throw new SemanticException(ErrorMsg.UNION_NOTIN_SUBQ.getMsg(ast)); + default: skipRecursion = false; break;