diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezProcContext.java ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezProcContext.java index cf43743..827637a 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezProcContext.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezProcContext.java @@ -65,6 +65,12 @@ // first operator of a reduce task. public Operator currentRootOperator; + // this is the original parent of the currentRootOperator as we scan + // through the graph. A root operator might have multiple parents and + // we just use this one to remember where we came from in the current + // walk. + public Operator parentOfRoot; + // tez task we're currently processing public TezTask currentTask; diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezWork.java ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezWork.java index 48145ad..ff8b17b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezWork.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezWork.java @@ -101,12 +101,13 @@ public Object process(Node nd, Stack stack, reduceWork.setReducer(root); reduceWork.setNeedsTagging(GenMapRedUtils.needsTagging(reduceWork)); - // All parents should be reduce sinks. We pick the first to choose the - // number of reducers. In the join/union case they will all be -1. In - // sort/order case where it matters there will be only one parent. - assert root.getParentOperators().get(0) instanceof ReduceSinkOperator; - ReduceSinkOperator reduceSink - = (ReduceSinkOperator)root.getParentOperators().get(0); + // All parents should be reduce sinks. We pick the one we just walked + // to choose the number of reducers. In the join/union case they will + // all be -1. In sort/order case where it matters there will be only + // one parent. + assert context.parentOfRoot instanceof ReduceSinkOperator; + ReduceSinkOperator reduceSink = (ReduceSinkOperator) context.parentOfRoot; + reduceWork.setNumReduceTasks(reduceSink.getConf().getNumReducers()); // need to fill in information about the key and value in the reducer @@ -165,9 +166,11 @@ public Object process(Node nd, Stack stack, // the next item will be a new root. if (!operator.getChildOperators().isEmpty()) { assert operator.getChildOperators().size() == 1; + context.parentOfRoot = operator; context.currentRootOperator = operator.getChildOperators().get(0); context.preceedingWork = work; } else { + context.parentOfRoot = null; context.currentRootOperator = null; context.preceedingWork = null; }