public static PrunedPartitionList prune(Table tab, ExprNodeDesc prunerExpr,
      HiveConf conf, String alias, Map<String, PrunedPartitionList> prunedPartitionsMap)
          throws SemanticException {

    if (LOG.isTraceEnabled()) {
      LOG.trace("Started pruning partition");
      LOG.trace("dbname = " + tab.getDbName());
      LOG.trace("tabname = " + tab.getTableName());
      LOG.trace("prune Expression = " + (prunerExpr == null ? "" : prunerExpr));
    }

    String key = tab.getFullyQualifiedName() + ";";
    if (tab.getMetaTable() != null) {
      key = tab.getFullyQualifiedName() + "." + tab.getMetaTable() + ";";
    } else if (tab.getSnapshotRef() != null) {
      key = tab.getFullyQualifiedName() + "." + tab.getSnapshotRef() + ";";
    }

    if (!tab.isPartitioned()) {
      // If the table is not partitioned, return empty list.
      return getAllPartsFromCacheOrServer(tab, key, false, prunedPartitionsMap);
    }

    if (!hasColumnExpr(prunerExpr)) {
      // If the "strict" mode is on, we have to provide partition pruner for each table.
      String error = StrictChecks.checkNoPartitionFilter(conf);
      if (error != null) {
        throw new SemanticException(error + " No partition predicate for Alias \""
            + alias + "\" Table \"" + tab.getTableName() + "\"");
      }
    }

    if (prunerExpr == null) {
      // In non-strict mode and there is no predicates at all - get everything.
      return getAllPartsFromCacheOrServer(tab, key, false, prunedPartitionsMap);
    }

    Set<String> partColsUsedInFilter = new LinkedHashSet<>();
    // Replace virtual columns with nulls. See javadoc for details.
    prunerExpr = removeNonPartCols(prunerExpr, tab.getPartColNames(), partColsUsedInFilter);
    // Remove all parts that are not partition columns. See javadoc for details.
    ExprNodeDesc compactExpr = compactExpr(prunerExpr.clone());
    String oldFilter = prunerExpr.getExprString(true);
    if (compactExpr == null || isBooleanExpr(compactExpr)) {
      if (isFalseExpr(compactExpr)) {
        return new PrunedPartitionList(tab, key + compactExpr.getExprString(true),
            Collections.emptySet(), Collections.emptyList(), false);
      }
      // For null and true values, return every partition
      return getAllPartsFromCacheOrServer(tab, key, true, prunedPartitionsMap);
    }

    String compactExprString = compactExpr.getExprString(true);
    LOG.debug("Filter w/ compacting: {}; filter w/o compacting: {}", compactExprString, oldFilter);
    key = key + compactExprString;
    PrunedPartitionList ppList = prunedPartitionsMap.get(key);
    if (ppList != null) {
      return ppList;
    }

    ppList = getPartitionsFromServer(tab, key, compactExpr,
        conf, partColsUsedInFilter, oldFilter.equals(compactExprString));
    prunedPartitionsMap.put(key, ppList);
    return ppList;
  }
Get the partition list for the table that satisfies the partition pruner
condition.

@param tab
         the table object for the alias
@param prunerExpr
         the pruner expression for the alias
@param conf
         for checking whether "strict" mode is on.
@param alias
         for generating error message only.
@param prunedPartitionsMap
         cached result for the table
@return the partition list for the table that satisfies the partition
        pruner condition.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java