diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMRFileSink1.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMRFileSink1.java index 25c6b24f46..8646acd56b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMRFileSink1.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMRFileSink1.java @@ -71,16 +71,20 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx opProcCtx, boolean chDir = false; // we should look take the parent of fsOp's task as the current task. FileSinkOperator fsOp = (FileSinkOperator) nd; - Map, GenMapRedCtx> mapCurrCtx = ctx - .getMapCurrCtx(); - GenMapRedCtx mapredCtx = mapCurrCtx.get(fsOp.getParentOperators().get(0)); - Task currTask = mapredCtx.getCurrTask(); - - ctx.setCurrTask(currTask); - ctx.addRootIfPossible(currTask); boolean isInsertTable = // is INSERT OVERWRITE TABLE GenMapRedUtils.isInsertInto(parseCtx, fsOp); + + Task currTask = ctx.getCurrTask(); + if (isInsertTable) { + Map, GenMapRedCtx> mapCurrCtx = ctx + .getMapCurrCtx(); + GenMapRedCtx mapredCtx = mapCurrCtx.get(fsOp.getParentOperators().get(0)); + currTask = mapredCtx.getCurrTask(); + ctx.setCurrTask(currTask); + } + + ctx.addRootIfPossible(currTask); HiveConf hconf = parseCtx.getConf(); // Mark this task as a final map reduce task (ignoring the optional merge task) diff --git ql/src/test/results/clientpositive/input13.q.out ql/src/test/results/clientpositive/input13.q.out index a54ca00b30..155eb3f144 100644 --- ql/src/test/results/clientpositive/input13.q.out +++ ql/src/test/results/clientpositive/input13.q.out @@ -51,17 +51,17 @@ STAGE DEPENDENCIES: Stage-10 depends on stages: Stage-4 , consists of Stage-7, Stage-6, Stage-8 Stage-7 Stage-0 depends on stages: Stage-7, Stage-6, Stage-9 - Stage-5 depends on stages: Stage-0, Stage-12, Stage-14, Stage-3 + Stage-5 depends on stages: Stage-0, Stage-12, Stage-3 Stage-6 Stage-8 Stage-9 depends on stages: Stage-8 Stage-1 depends on stages: Stage-4 - Stage-11 depends on stages: Stage-1, Stage-12, Stage-14, Stage-3 + Stage-11 depends on stages: Stage-1, Stage-12, Stage-3 Stage-12 depends on stages: Stage-4 - Stage-13 depends on stages: Stage-2, Stage-12, Stage-14, Stage-3 + Stage-13 depends on stages: Stage-2, Stage-12, Stage-3 Stage-2 depends on stages: Stage-4 Stage-14 depends on stages: Stage-4 - Stage-3 depends on stages: Stage-4 + Stage-3 depends on stages: Stage-14 STAGE PLANS: Stage: Stage-4