public static ReduceSinkDesc getReduceSinkDesc(
      final List<ExprNodeDesc> keyCols, int numKeys,
      List<ExprNodeDesc> valueCols,
      List<List<Integer>> distinctColIndices,
      List<String> outputKeyColumnNames,
      List<String> outputValueColumnNames,
      boolean includeKeyCols, int tag,
      List<ExprNodeDesc> partitionCols, String order, String nullOrder, NullOrdering defaultNullOrder,
      int numReducers, AcidUtils.Operation writeType) {
    TableDesc keyTable;
    TableDesc valueTable;
    List<String> outputKeyCols = new ArrayList<>();
    List<String> outputValCols = new ArrayList<>();
    if (includeKeyCols) {
      List<FieldSchema> keySchema = getFieldSchemasFromColumnListWithLength(
          keyCols, distinctColIndices, outputKeyColumnNames, numKeys, "");
      if (order.length() < outputKeyColumnNames.size()) {
        order = order + "+";
      }
      if (nullOrder.length() < outputKeyColumnNames.size()) {
        nullOrder = nullOrder + defaultNullOrder.getSign();
      }
      keyTable = getReduceKeyTableDesc(keySchema, order, nullOrder);
      outputKeyCols.addAll(outputKeyColumnNames);
    } else {
      keyTable = getReduceKeyTableDesc(getFieldSchemasFromColumnList(
          keyCols, "reducesinkkey"), order, nullOrder);
     for (int i = 0; i < keyCols.size(); i++) {
        outputKeyCols.add("reducesinkkey" + i);
      }
    }
    valueTable = getReduceValueTableDesc(getFieldSchemasFromColumnList(
        valueCols, outputValueColumnNames, 0, ""));
    outputValCols.addAll(outputValueColumnNames);
    return new ReduceSinkDesc(keyCols, numKeys, valueCols, outputKeyCols,
        distinctColIndices, outputValCols,
        tag, partitionCols, numReducers, keyTable,
        valueTable, writeType);
  }
Create the reduce sink descriptor.

@param keyCols
         The columns to be stored in the key
@param numKeys
         number of distribution key numbers. Equals to group-by-key
         numbers usually.
@param valueCols
         The columns to be stored in the value
@param distinctColIndices
         column indices for distinct aggregate parameters
@param outputKeyColumnNames
         The output key columns names
@param outputValueColumnNames
         The output value columns names
@param tag
         The tag for this reducesink
@param partitionCols
         The columns for partitioning.
@param numReducers
         The number of reducers, set to -1 for automatic inference based on
         input data size.
@param writeType Whether this is an Acid write, and if so whether it is insert, update,
                 or delete.
@return The reduceSinkDesc object.
ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java