protected boolean checkConvertJoinToSMBJoin(
      JoinOperator joinOperator,
      SortBucketJoinProcCtx smbJoinContext) throws SemanticException {

    if (!this.pGraphContext.getJoinOps().contains(joinOperator)) {
      return false;
    }

    String[] srcs = joinOperator.getConf().getBaseSrc();

    // All the tables/partitions columns should be sorted in the same order
    // For example, if tables A and B are being joined on columns c1, c2 and c3
    // which are the sorted and bucketed columns. The join would work, as long
    // c1, c2 and c3 are sorted in the same order.
    List<Order> sortColumnsFirstTable = new ArrayList<Order>();

    for (int pos = 0; pos < srcs.length; pos++) {
      if (!isEligibleForBucketSortMergeJoin(smbJoinContext,
          smbJoinContext.getKeyExprMap().get((byte) pos),
          joinOperator.getConf().getAliasToOpInfo(),
          srcs,
          pos,
          sortColumnsFirstTable)) {
        return false;
      }
    }

    smbJoinContext.setSrcs(srcs);
    return true;
  }
Whether this table is eligible for a sort-merge join.

@param pctx                  parse context
@param op                    map join operator being considered
@param joinTree              join tree being considered
@param alias                 table alias in the join tree being checked
@param pos                   position of the table
@param sortColumnsFirstTable The names and order of the sorted columns for the first table.
                             It is not initialized when pos = 0.
@return
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/optimizer/AbstractSMBJoinProc.java