private static double getProbeDecodeNDVRatio(TableScanOperator tsOp, MapJoinOperator mjOp) {
    long mjKeyCardinality = mjOp.getStatistics().getNumRows();
    long tsKeyCardinality = tsOp.getStatistics().getNumRows();

    byte posBigTable = (byte) mjOp.getConf().getPosBigTable();

    Byte[] order = mjOp.getConf().getTagOrder();
    Byte mjSmallTablePos = (order[0] == posBigTable ? order[1] : order[0]);
    Byte mjBigTablePos = (order[0] == posBigTable ? order[0] : order[1]);

    // Single Key MJ at this point
    List<ExprNodeDesc> tsKeyDesc = mjOp.getConf().getKeys().get(mjBigTablePos);
    List<ExprNodeDesc> mjKeyDesc = mjOp.getConf().getKeys().get(mjSmallTablePos);
    if (mjKeyDesc.get(0) instanceof ExprNodeColumnDesc) {
      ExprNodeColumnDesc tsKeyCol = (ExprNodeColumnDesc) tsKeyDesc.get(0);
      ExprNodeColumnDesc mjKeyCol = (ExprNodeColumnDesc) mjKeyDesc.get(0);

      ColStatistics mjStats = mjOp.getStatistics().getColumnStatisticsFromColName(mjKeyCol.getColumn());
      ColStatistics tsStats = tsOp.getStatistics().getColumnStatisticsFromColName(tsKeyCol.getColumn());

      if (canUseNDV(mjStats)) {
        mjKeyCardinality = mjStats.getCountDistint();
      }
      if (canUseNDV(tsStats)) {
        tsKeyCardinality = tsStats.getCountDistint();
      }
    }
    return mjKeyCardinality / (double) tsKeyCardinality;
  }
TezCompiler translates the operator plan into TezTasks.
ql/src/java/org/apache/hadoop/hive/ql/parse/TezCompiler.java