private static int isSuitableFilter(
      HiveLoptMultiJoin multiJoin,
      RexNode joinFilter,
      int factIdx) {
    // ignore non-equality filters where the operands are not
    // RexInputRefs
    switch (joinFilter.getKind()) {
    case EQUALS:
      break;
    default:
      return -1;
    }
    List<RexNode> operands = ((RexCall) joinFilter).getOperands();
    if (!(operands.get(0) instanceof RexInputRef)
        || !(operands.get(1) instanceof RexInputRef)) {
      return -1;
    }

    // filter is suitable if each side of the filter only contains a
    // single factor reference and one side references the fact table and
    // the other references the dimension table; since we know this is
    // a join filter and we've already verified that the operands are
    // RexInputRefs, verify that the factors belong to the fact and
    // dimension table
    ImmutableBitSet joinRefs = multiJoin.getFactorsRefByJoinFilter(joinFilter);
    assert joinRefs.cardinality() == 2;
    int factor1 = joinRefs.nextSetBit(0);
    int factor2 = joinRefs.nextSetBit(factor1 + 1);
    if (factor1 == factIdx) {
      return factor2;
    }
    if (factor2 == factIdx) {
      return factor1;
    }
    return -1;
  }
Determines if a join filter can be used with a semijoin against a
specified fact table. A suitable filter is of the form "factable.col1 =
dimTable.col2".

@param multiJoin join factors being optimized
@param joinFilter filter to be analyzed
@param factIdx index corresponding to the fact table

@return index of corresponding dimension table if the filter is
appropriate; otherwise -1 is returned
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveLoptSemiJoinOptimizer.java