public static Optional<Set<String>> colMappingInverseKeys(ReduceSinkOperator rs) {
    Map<String, String> ret = new HashMap<String, String>();
    Map<String, ExprNodeDesc> exprMap = rs.getColumnExprMap();
    Set<String> neededColumns = new HashSet<String>();

    if (!rs.getSchema().getColumnNames().stream().allMatch(exprMap::containsKey)) {
      // Cannot invert RS because exprMap does not contain all of RS's input columns.
      return Optional.empty();
    }

    try {
      for (Entry<String, ExprNodeDesc> e : exprMap.entrySet()) {
        String columnName = extractColumnName(e.getValue());
        if (rs.getSchema().getColumnInfo(e.getKey()) == null) {
          // ignore incorrectly mapped columns (if there's any) - but require its input to be present
          neededColumns.add(columnName);
        } else {
          ret.put(columnName, e.getKey());
        }
      }
      neededColumns.removeAll(ret.keySet());
      if (!neededColumns.isEmpty()) {
        // There is no way to compute all parts of neededColumns
        return Optional.empty();
      }
      return Optional.of(new TreeSet<>(ret.values()));
    } catch (SemanticException e) {
      return Optional.empty();
    }
  }
Fixes a parallel edge going into a mapjoin by introducing a concentrator RS.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ParallelEdgeFixer.java