List<Partition> getPartitionsByFilter(final String filter) throws MetaException {
    if (filter == null || filter.isEmpty()) {
      return new ArrayList<>(parts.values());
    }
    List<Partition> result = new ArrayList<>();
    ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript");
    if (se == null) {
      LOG.error("JavaScript script engine is not found, therefore partition filtering "
          + "for temporary tables is disabled.");
      return result;
    }
    for (Map.Entry<String, Partition> entry : parts.entrySet()) {
      se.put("partitionName", entry.getKey());
      se.put("values", entry.getValue().getValues());
      try {
        if ((Boolean)se.eval(filter)) {
          result.add(entry.getValue());
        }
      } catch (ScriptException e) {
        throw new MetaException("Incorrect partition filter");
      }
    }
    return result;
  }
Return a list of partitions matching the filter.
@param filter filter string, must be not null.
@return list of partitions, always not-null.
@throws MetaException
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java