private static void extractFinalCandidates(ExprNodeDesc expr,
      ExprWalkerInfo ctx, HiveConf conf) {
    // We decompose an AND expression into its parts before checking if the
    // entire expression is a candidate because each part may be a candidate
    // for replicating transitively over an equijoin condition.
    if (FunctionRegistry.isOpAnd(expr)) {
      // If the operator is AND, we need to determine if any of the children are
      // final candidates.

      // For the children, we populate the NewToOldExprMap to keep track of
      // the original condition before rewriting it for this operator
      assert ctx.getNewToOldExprMap().containsKey(expr);
      List<ExprNodeDesc> exprChildren = expr.getChildren();
      List<ExprNodeDesc> newToOldList = ctx.getNewToOldExprMap().get(expr).getChildren();
      for (int i = 0; i < expr.getChildren().size(); i++) {
        ctx.getNewToOldExprMap().put(exprChildren.get(i), newToOldList.get(i));
        extractFinalCandidates(exprChildren.get(i), ctx, conf);
      }
      return;
    }

    ExprInfo exprInfo = ctx.getExprInfo(expr);
    if (exprInfo != null && exprInfo.isCandidate) {
      String alias = exprInfo.alias;
      if ((alias == null) && (exprInfo.convertedExpr != null)) {
    	ExprInfo convertedExprInfo = ctx.getExprInfo(exprInfo.convertedExpr);
    	if (convertedExprInfo != null) {
    		alias = convertedExprInfo.alias;
    	}
      }
      ctx.addFinalCandidate(alias, exprInfo.convertedExpr != null ?
              exprInfo.convertedExpr : expr);
      return;
    } else if (!FunctionRegistry.isOpAnd(expr) &&
        HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_PPD_REMOVE_DUPLICATE_FILTERS)) {
      ctx.addNonFinalCandidate(exprInfo != null ? exprInfo.alias : null, expr);
    }
  }
Walks through the top AND nodes and determine which of them are final
candidates.
ql/src/java/org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java