@SuppressWarnings({"nls"})
  private Operator genGroupByPlan1MR(String dest, QB qb, Operator input)
      throws SemanticException {

    QBParseInfo parseInfo = qb.getParseInfo();

    int numReducers = -1;
    Pair<List<ASTNode>, List<Long>> grpByExprsGroupingSets = getGroupByGroupingSetsForClause(parseInfo, dest);

    List<ASTNode> grpByExprs = grpByExprsGroupingSets.getLeft();
    List<Long> groupingSets = grpByExprsGroupingSets.getRight();

    if (grpByExprs.isEmpty()) {
      numReducers = 1;
    }

    // Grouping sets are not allowed
    if (!groupingSets.isEmpty()) {
      throw new SemanticException(ErrorMsg.HIVE_GROUPING_SETS_AGGR_NOMAPAGGR.getMsg());
    }

    // ////// 1. Generate ReduceSinkOperator
    ReduceSinkOperator reduceSinkOperatorInfo =
        genGroupByPlanReduceSinkOperator(qb,
            dest,
            input,
            grpByExprs,
            grpByExprs.size(),
            false,
            numReducers,
            false,
            false);

    // ////// 2. Generate GroupbyOperator
    Operator groupByOperatorInfo = genGroupByPlanGroupByOperator(parseInfo,
        dest, reduceSinkOperatorInfo, reduceSinkOperatorInfo, GroupByDesc.Mode.COMPLETE, null);

    return groupByOperatorInfo;
  }
Generate a Group-By plan using a single map-reduce job (3 operators will be
inserted):

ReduceSink ( keys = (K1_EXP, K2_EXP, DISTINCT_EXP), values = (A1_EXP,
A2_EXP) ) SortGroupBy (keys = (KEY.0,KEY.1), aggregations =
(count_distinct(KEY.2), sum(VALUE.0), count(VALUE.1))) Select (final
selects).

@param dest
@param qb
@param input
@return
@throws SemanticException

          Generate a Group-By plan using 1 map-reduce job. Spray by the
          group by key, and sort by the distinct key (if any), and compute
          aggregates * The aggregation evaluation functions are as
          follows: Partitioning Key: grouping key

          Sorting Key: grouping key if no DISTINCT grouping + distinct key
          if DISTINCT

          Reducer: iterate/merge (mode = COMPLETE)
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java