private static RexNode swapFilter(
          RexBuilder rexBuilder,
          HiveLoptMultiJoin multiJoin,
          HiveLoptJoinTree origLeft,
          HiveLoptJoinTree origRight,
          RexNode condition) {
    int nFieldsOnLeft =
            origLeft.getJoinTree().getRowType().getFieldCount();
    int nFieldsOnRight =
            origRight.getJoinTree().getRowType().getFieldCount();
    int [] adjustments = new int[nFieldsOnLeft + nFieldsOnRight];

    for (int i = 0; i < nFieldsOnLeft; i++) {
      adjustments[i] = nFieldsOnRight;
    }
    for (int i = nFieldsOnLeft; i < (nFieldsOnLeft + nFieldsOnRight); i++) {
      adjustments[i] = -nFieldsOnLeft;
    }

    condition =
            condition.accept(
                    new RelOptUtil.RexInputConverter(
                            rexBuilder,
                            multiJoin.getJoinFields(origLeft, origRight),
                            multiJoin.getJoinFields(origRight, origLeft),
                            adjustments));

    return condition;
  }
Adjusts a filter to reflect swapping of join inputs.

@param rexBuilder rexBuilder
@param multiJoin join factors being optimized
@param origLeft original LHS of the join tree (before swap)
@param origRight original RHS of the join tree (before swap)
@param condition original join condition

@return join condition reflect swap of join inputs
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveLoptOptimizeJoinRule.java