Index: ql/src/test/results/clientnegative/subq_insert.q.out =================================================================== --- ql/src/test/results/clientnegative/subq_insert.q.out (revision 0) +++ ql/src/test/results/clientnegative/subq_insert.q.out (revision 0) @@ -0,0 +1 @@ +FAILED: Error in semantic analysis: line 2:38 Subquery Insert to src1 Index: ql/src/test/queries/clientnegative/subq_insert.q =================================================================== --- ql/src/test/queries/clientnegative/subq_insert.q (revision 0) +++ ql/src/test/queries/clientnegative/subq_insert.q (revision 0) @@ -0,0 +1,2 @@ +EXPLAIN +SELECT * FROM (INSERT OVERWRITE TABLE src1 SELECT * FROM src ) y; Index: ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (revision 724570) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (working copy) @@ -43,6 +43,7 @@ DUPLICATE_GROUPBY_KEY("Repeated Key in Group By"), UNSUPPORTED_MULTIPLE_DISTINCTS("DISTINCT on Different Columns not Supported"), NO_SUBQUERY_ALIAS("No Alias For Subquery"), + NO_INSERT_INSUBQUERY("Subquery Insert to "), NON_KEY_EXPR_IN_GROUPBY("Expression Not In Group By Key"), INVALID_XPATH("General . and [] Operators are Not Supported"), INVALID_PATH("Invalid Path"), Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 724570) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -343,6 +343,14 @@ ctx_1.dest = "insclause-" + ctx_1.nextNum; ctx_1.nextNum++; + // is there a insert in the subquery + if (qbp.getIsSubQ()) { + CommonTree ch = (CommonTree)ast.getChild(0); + if ((ch.getToken().getType() != HiveParser.TOK_DIR) || + (((CommonTree)ch.getChild(0)).getToken().getType() != HiveParser.TOK_TMP_FILE)) + throw new SemanticException(ErrorMsg.NO_INSERT_INSUBQUERY.getMsg(ast)); + } + qbp.setDestForClause(ctx_1.dest, (CommonTree) ast.getChild(0)); } break;