private static RelNode replaceExpressionsUsingMap(RelNode plan, Map<RexNode, RexNode> mapping) {
    CallReplacer replacer = new CallReplacer(mapping);
    return plan.accept(new RelHomogeneousShuttle() {
      @Override public RelNode visit(RelNode other) {
        RelNode mNode = super.visitChildren(other);
        return mNode.accept(replacer);
      }
    });
  }
Replaces all row expressions in the plan using the provided mapping.

@param plan the relational expression on which we want to perform the replacements.
@param mapping a mapping defining how to replace row expressions in the plan
@return a new relational expression where all expressions present in the mapping are replaced.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/CorrelateProjectExtractor.java