@Override
  public HCatPartition getPartition(String dbName, String tableName,
                    Map<String, String> partitionSpec) throws HCatException {
    HCatPartition partition = null;
    try {
      HCatTable hcatTable = getTable(dbName, tableName);
      List<HCatFieldSchema> partitionColumns = hcatTable.getPartCols();
      if (partitionColumns.size() != partitionSpec.size()) {
        throw new HCatException("Partition-spec doesn't have the right number of partition keys.");
      }

      ArrayList<String> ptnValues = new ArrayList<String>();
      for (HCatFieldSchema partitionColumn : partitionColumns) {
        String partKey = partitionColumn.getName();
        if (partitionSpec.containsKey(partKey)) {
          ptnValues.add(partitionSpec.get(partKey)); // Partition-keys added in order.
        }
        else {
          throw new HCatException("Invalid partition-key specified: " + partKey);
        }
      }
      Partition hivePartition = hmsClient.getPartition(checkDB(dbName),
        tableName, ptnValues);
      if (hivePartition != null) {
        partition = new HCatPartition(hcatTable, hivePartition);
      }
    } catch (MetaException e) {
      throw new HCatException(
        "MetaException while retrieving partition.", e);
    } catch (NoSuchObjectException e) {
      throw new ObjectNotFoundException(
        "NoSuchObjectException while retrieving partition.", e);
    } catch (TException e) {
      throw new ConnectionFailureException(
          "TException while retrieving partition.", e);
    }
    return partition;
  }
The HCatClientHMSImpl is the Hive Metastore client based implementation of
HCatClient.
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/HCatClientHMSImpl.java