static List<Partition> convertFromPartSpec(Iterator<PartitionSpec> iterator, Table tbl)
      throws HiveException, TException {
    if(!iterator.hasNext()) {
      return Collections.emptyList();
    }
    List<Partition> results = new ArrayList<>();

    while (iterator.hasNext()) {
      PartitionSpec partitionSpec = iterator.next();
      if (partitionSpec.getPartitionList() != null) {
        // partitions outside table location
        Iterator<org.apache.hadoop.hive.metastore.api.Partition> externalPartItr =
            partitionSpec.getPartitionList().getPartitions().iterator();
        while(externalPartItr.hasNext()) {
          org.apache.hadoop.hive.metastore.api.Partition msPart =
              externalPartItr.next();
          results.add(new Partition(tbl, msPart));
        }
      } else {
        // partitions within table location
        for(PartitionWithoutSD partitionWithoutSD:partitionSpec.getSharedSDPartitionSpec().getPartitions()) {
          org.apache.hadoop.hive.metastore.api.Partition part = new org.apache.hadoop.hive.metastore.api.Partition();
          part.setTableName(partitionSpec.getTableName());
          part.setDbName(partitionSpec.getDbName());
          part.setCatName(partitionSpec.getCatName());
          part.setCreateTime(partitionWithoutSD.getCreateTime());
          part.setLastAccessTime(partitionWithoutSD.getLastAccessTime());
          part.setParameters(partitionWithoutSD.getParameters());
          part.setPrivileges(partitionWithoutSD.getPrivileges());
          part.setSd(partitionSpec.getSharedSDPartitionSpec().getSd().deepCopy());
          String partitionLocation = null;
          if(partitionWithoutSD.getRelativePath() == null
              || partitionWithoutSD.getRelativePath().isEmpty()) {
            if (tbl.getDataLocation() != null) {
              Path partPath = new Path(tbl.getDataLocation(),
                  Warehouse.makePartName(tbl.getPartCols(),
                      partitionWithoutSD.getValues()));
              partitionLocation = partPath.toString();
            }
          } else {
            partitionLocation = tbl.getSd().getLocation();
            partitionLocation += partitionWithoutSD.getRelativePath();
          }
          part.getSd().setLocation(partitionLocation);
          part.setValues(partitionWithoutSD.getValues());
          part.setWriteId(partitionSpec.getWriteId());
          Partition hivePart = new Partition(tbl, part);
          results.add(hivePart);
        }
      }
    }
    return results;
  }
Get a list of Partitions by filter.
@param tbl The table containing the partitions.
@param filter A string represent partition predicates.
@return a list of partitions satisfying the partition predicates.
@throws HiveException
@throws MetaException
@throws NoSuchObjectException
@throws TException
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java