@Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
        throws SemanticException {
      Operator<?> o = (Operator<?>) nd;
      OpGroup g;
      if (nodeOutputs.length == 0) {
        g = newGroup(procCtx);
      } else {
        g = (OpGroup) nodeOutputs[0];
      }
      for (int i = 1; i < nodeOutputs.length; i++) {
        g.merge((OpGroup) nodeOutputs[i]);
      }
      g.add(o);
      if (o instanceof ReduceSinkOperator) {
        // start a new group before the reduceSinkOperator
        return newGroup(procCtx);
      } else {
        return g;
      }
    }
This rule decomposes the operator tree into group which may have different bucketing versions.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/BucketVersionPopulator.java