public static Partition createMetaPartitionObject(Table tbl, Map<String, String> partSpec, Path location)
    throws MetastoreException {
    List<String> pvals = new ArrayList<String>();
    for (FieldSchema field : getPartCols(tbl)) {
      String val = partSpec.get(field.getName());
      if (val == null || val.isEmpty()) {
        throw new MetastoreException("partition spec is invalid; field "
          + field.getName() + " does not exist or is empty");
      }
      pvals.add(val);
    }

    Partition tpart = new Partition();
    tpart.setCatName(tbl.getCatName());
    tpart.setDbName(tbl.getDbName());
    tpart.setTableName(tbl.getTableName());
    tpart.setValues(pvals);

    if (!MetaStoreUtils.isView(tbl)) {
      tpart.setSd(tbl.getSd().deepCopy());
      tpart.getSd().setLocation((location != null) ? location.toString() : null);
    }
    return tpart;
  }
Get the partition name from the path.

@param tablePath
         Path of the table.
@param partitionPath
         Path of the partition.
@param partCols
         Set of partition columns from table definition
@return Partition name, for example partitiondate=2008-01-01
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java