private Map<ExprNodeDesc, ExprNodeDesc> searchForEqualities(
            JoinOperator join, int sourcePos, ReduceSinkOperator source, Set<ExprNodeColumnDesc> startNodes) {
      Map<ExprNodeDesc, String> equalities = searchForEqualities(source, startNodes);
      if (equalities.isEmpty()) {
        return Collections.emptyMap();
      }

      Map<ExprNodeDesc, ExprNodeDesc> replaceMap = new HashMap<>(equalities.size());
      for (Entry<ExprNodeDesc, String> eqEntry : equalities.entrySet()) {
        for (Entry<String, ExprNodeDesc> joinColMapEntry : join.getColumnExprMap().entrySet()) {
          if (join.getConf().getReversedExprs().get(joinColMapEntry.getKey()) != sourcePos) {
            continue;
          }
          if (!(joinColMapEntry.getValue() instanceof ExprNodeColumnDesc)) {
            continue;
          }
          if (((ExprNodeColumnDesc) joinColMapEntry.getValue()).getColumn().equals(eqEntry.getValue())) {
            replaceMap.put(eqEntry.getKey(), joinColMapEntry.getValue());
            break;
          }
        }
      }

      return replaceMap;
    }
Traverse the operator tree and collect equal columns.
Traversal starts from the specified source operator to TableScan operators.
This method calls searchForEqualities(Operator<?> operator, Set<ExprNodeColumnDesc> exprNodeDescSet)
to find equalities. Since it returns a map where values are names of input columns of the join operator
this method maps these names to output column expression using the join operators columnExprMap.

@param join Parent operator of source operator
@param sourcePos Index of source operator in parent join branches. (0 or 1).
@param source root of operator tree to traverse
@param startNodes set of columns search equal columns for
@return Map of equal columns: key column coming from the passed exprNodeDescSet, value column equals to the key.
ql/src/java/org/apache/hadoop/hive/ql/ppd/OpProcFactory.java