public static boolean prunePartitionNames(List<String> partColumnNames,
      List<PrimitiveTypeInfo> partColumnTypeInfos, ExprNodeDesc prunerExpr,
      String defaultPartitionName, List<String> partNames) throws HiveException, MetaException {
    // Prepare the expression to filter on the columns.
    Pair<PrimitiveObjectInspector, ExprNodeEvaluator> handle =
        PartExprEvalUtils.prepareExpr(prunerExpr, partColumnNames, partColumnTypeInfos);

    // Filter the name list. Removing elements one by one can be slow on e.g. ArrayList,
    // so let's create a new list and copy it if we don't have a linked list
    boolean inPlace = partNames instanceof AbstractSequentialList<?>;
    List<String> partNamesSeq = inPlace ? partNames : new LinkedList<>(partNames);

    // Array for the values to pass to evaluator.
    ArrayList<String> values = new ArrayList<>(partColumnNames.size());
    for (int i = 0; i < partColumnNames.size(); ++i) {
      values.add(null);
    }

    boolean hasUnknownPartitions = false;
    Iterator<String> partIter = partNamesSeq.iterator();
    while (partIter.hasNext()) {
      String partName = partIter.next();
      Warehouse.makeValsFromName(partName, values);

      List<Object> convertedValues = new ArrayList<>(values.size());
      for(int i=0; i<values.size(); i++) {
        String partitionValue = values.get(i);
        PrimitiveTypeInfo typeInfo = partColumnTypeInfos.get(i);

        if (partitionValue.equals(defaultPartitionName)) {
          convertedValues.add(null); // Null for default partition.
        } else {
          Object o = ObjectInspectorConverters.getConverter(
              PrimitiveObjectInspectorFactory.javaStringObjectInspector,
              PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(typeInfo))
              .convert(partitionValue);
          convertedValues.add(o);
        }
      }

      // Evaluate the expression tree.
      Boolean isNeeded = (Boolean)PartExprEvalUtils.evaluateExprOnPart(handle, convertedValues);
      boolean isUnknown = (isNeeded == null);
      if (!isUnknown && !isNeeded) {
        partIter.remove();
        continue;
      }
      if (isUnknown && values.contains(defaultPartitionName)) {
        // Reject default partitions if we couldn't determine whether we should include it or not.
        // Note that predicate would only contains partition column parts of original predicate.
        LOG.debug("skipping default/bad partition: {}", partName);
        partIter.remove();
        continue;
      }
      hasUnknownPartitions |= isUnknown;
      LOG.debug("retained unknown:[{}] partition: {}", isUnknown, partName);

    }
    if (!inPlace) {
      partNames.clear();
      partNames.addAll(partNamesSeq);
    }
    return hasUnknownPartitions;
  }
Prunes partition names to see if they match the prune expression.
@param partColumnNames name of partition columns
@param partColumnTypeInfos types of partition columns
@param prunerExpr The expression to match.
@param defaultPartitionName name of default partition
@param partNames Partition names to filter. The list is modified in place.
@return Whether the list has any partitions for which the expression may or may not match.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java