private static OpAttr genReduceSideGB1NoMapGB(OpAttr inputOpAf, GBInfo gbInfo,
      GroupByDesc.Mode gbMode) throws SemanticException {
    ArrayList<String> outputColNames = new ArrayList<String>();
    ArrayList<ColumnInfo> colInfoLst = new ArrayList<ColumnInfo>();
    Map<String, ExprNodeDesc> colExprMap = new HashMap<String, ExprNodeDesc>();
    String colOutputName = null;
    ReduceSinkOperator rs = (ReduceSinkOperator) inputOpAf.inputs.get(0);
    List<ColumnInfo> rsColInfoLst = rs.getSchema().getSignature();
    ColumnInfo ci;
    boolean useOriginalGBNames = (gbInfo.gbPhysicalPipelineMode == HIVEGBPHYSICALMODE.NO_MAP_SIDE_GB_NO_SKEW);

    // 1. Build GB Keys, grouping set starting position
    // 1.1 First Add original GB Keys
    ArrayList<ExprNodeDesc> gbKeys = ExprNodeDescUtils.genExprNodeDesc(rs, 0,
        gbInfo.gbKeys.size() - 1, true, false);
    for (int i = 0; i < gbInfo.gbKeys.size(); i++) {
      ci = rsColInfoLst.get(i);
      if (useOriginalGBNames) {
        colOutputName = gbInfo.outputColNames.get(i);
      } else {
        colOutputName = SemanticAnalyzer.getColumnInternalName(i);
      }
      outputColNames.add(colOutputName);
      colInfoLst.add(new ColumnInfo(colOutputName, ci.getType(), null, false));
      colExprMap.put(colOutputName, gbKeys.get(i));
    }

    // 2. Walk through UDAF and add them to GB
    String lastReduceKeyColName = null;
    if (!rs.getConf().getOutputKeyColumnNames().isEmpty()) {
      lastReduceKeyColName = rs.getConf().getOutputKeyColumnNames()
          .get(rs.getConf().getOutputKeyColumnNames().size() - 1);
    }
    int numDistinctUDFs = 0;
    List<ExprNodeDesc> reduceValues = rs.getConf().getValueCols();
    ArrayList<AggregationDesc> aggregations = new ArrayList<AggregationDesc>();
    int udafColStartPosInOriginalGB = gbInfo.gbKeys.size();

    final List<List<ColumnInfo>> paramColInfoTable = new ArrayList<>(gbInfo.udafAttrs.size());
    final List<List<String>> distinctColumnNameTable = new ArrayList<>(gbInfo.udafAttrs.size());
    final Map<ColumnInfo, String> distinctColumnMapping = new HashMap<>();
    for (int i = 0; i < gbInfo.udafAttrs.size(); i++) {
      final UDAFAttrs udafAttr = gbInfo.udafAttrs.get(i);
      final List<ColumnInfo> paramColInfo = new ArrayList<>(udafAttr.udafParams.size());
      final List<String> distinctColNames = new ArrayList<>(udafAttr.udafParams.size());

      for (int j = 0; j < udafAttr.udafParams.size(); j++) {
        final int argPos = getColInfoPos(udafAttr.udafParams.get(j), gbInfo);
        final ColumnInfo rsUDAFParamColInfo = rsColInfoLst.get(argPos);
        paramColInfo.add(rsUDAFParamColInfo);

        final String distinctColumnName;
        if (udafAttr.isDistinctUDAF && lastReduceKeyColName != null) {
          distinctColumnName = Utilities.ReduceField.KEY.name() + "." + lastReduceKeyColName
                  + ":" + numDistinctUDFs + "." + SemanticAnalyzer.getColumnInternalName(j);
          distinctColumnMapping.putIfAbsent(rsUDAFParamColInfo, distinctColumnName);
        } else {
          distinctColumnName = null;
        }
        distinctColNames.add(distinctColumnName);
      }

      paramColInfoTable.add(paramColInfo);
      distinctColumnNameTable.add(distinctColNames);

      if(udafAttr.isDistinctUDAF) {
        numDistinctUDFs++;
      }
    }

    // the positions in rsColInfoLst are as follows
    // --grpkey--,--distkey--,--values--
    // but distUDAF may be before/after some non-distUDAF,
    // i.e., their positions can be mixed.
    // so for all UDAF we first check to see if it is groupby key, if not is it distinct key
    // if not it should be value
    final Map<Integer, List<ExprNodeDesc>> indexToParameter = new TreeMap<>();
    for (int i = 0; i < paramColInfoTable.size(); i++) {
      final ArrayList<ExprNodeDesc> aggParameters = new ArrayList<>();

      for (int j = 0; j < paramColInfoTable.get(i).size(); j++) {
        final ColumnInfo rsUDAFParamColInfo = paramColInfoTable.get(i).get(j);

        final String rsUDAFParamName;
        if (distinctColumnNameTable.get(i).get(j) != null) {
          rsUDAFParamName = distinctColumnNameTable.get(i).get(j);
        } else if (distinctColumnMapping.containsKey(rsUDAFParamColInfo)) {
          // This UDAF is not labeled with DISTINCT, but it refers to a DISTINCT key.
          // The original internal name could be already obsolete as any DISTINCT keys are renamed.
          rsUDAFParamName = distinctColumnMapping.get(rsUDAFParamColInfo);
        } else {
          rsUDAFParamName = rsUDAFParamColInfo.getInternalName();
        }
        ExprNodeDesc udafParam = new ExprNodeColumnDesc(rsUDAFParamColInfo.getType(), rsUDAFParamName,
                rsUDAFParamColInfo.getTabAlias(), rsUDAFParamColInfo.getIsVirtualCol());
        final ExprNodeDesc constantPropDistinctUDAFParam = SemanticAnalyzer
                .isConstantParameterInAggregationParameters(rsUDAFParamColInfo.getInternalName(),
                        reduceValues);
        if (constantPropDistinctUDAFParam != null) {
          udafParam = constantPropDistinctUDAFParam;
        }
        aggParameters.add(udafParam);
      }
      indexToParameter.put(i, aggParameters);
    }

    for(Map.Entry<Integer, List<ExprNodeDesc>> e : indexToParameter.entrySet()){
      UDAFAttrs udafAttr = gbInfo.udafAttrs.get(e.getKey());
      Mode udafMode = SemanticAnalyzer.groupByDescModeToUDAFMode(gbMode, udafAttr.isDistinctUDAF);
      GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo(udafAttr.udafEvaluator, udafMode,
          e.getValue());
      aggregations.add(new AggregationDesc(udafAttr.udafName.toLowerCase(),
          udaf.genericUDAFEvaluator, udaf.convertedParameters, udafAttr.isDistinctUDAF, udafMode));
      if (useOriginalGBNames) {
        colOutputName = gbInfo.outputColNames.get(udafColStartPosInOriginalGB + e.getKey());
      } else {
        colOutputName = SemanticAnalyzer.getColumnInternalName(gbKeys.size() + aggregations.size()
            - 1);
      }
      colInfoLst.add(new ColumnInfo(colOutputName, udaf.returnType, "", false));
      outputColNames.add(colOutputName);
    }

    Operator rsGB1 = OperatorFactory.getAndMakeChild(new GroupByDesc(gbMode, outputColNames,
        gbKeys, aggregations, false, gbInfo.groupByMemoryUsage, gbInfo.minReductionHashAggrLowerBound,
        gbInfo.hashAggrFlushPercent, gbInfo.memoryThreshold, gbInfo.minReductionHashAggr, null,
        false, -1, numDistinctUDFs > 0), new RowSchema(colInfoLst), rs);
    rsGB1.setColumnExprMap(colExprMap);

    return new OpAttr("", new HashSet<Integer>(), rsGB1);
  }
RS-GB0

@param inputOpAf
@param gbInfo
@param gbMode
@return
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/opconventer/HiveGBOpConvUtil.java