@Override
  public void addPartition(HCatAddPartitionDesc partInfo)
    throws HCatException {
    Table tbl = null;
    try {
      tbl = hmsClient.getTable(partInfo.getDatabaseName(),
          partInfo.getTableName());
      // TODO: Should be moved out.
      if (tbl.getPartitionKeysSize() == 0) {
        throw new HCatException("The table " + partInfo.getTableName()
          + " is not partitioned.");
      }

      HCatTable hcatTable = new HCatTable(tbl);

      HCatPartition hcatPartition = partInfo.getHCatPartition();

      // TODO: Remove in Hive 0.16.
      // This is only required to support the deprecated methods in HCatAddPartitionDesc.Builder.
      if (hcatPartition == null) {
        hcatPartition = partInfo.getHCatPartition(hcatTable);
      }

      hmsClient.add_partition(hcatPartition.toHivePartition());
    } catch (InvalidObjectException e) {
      throw new HCatException(
        "InvalidObjectException while adding partition.", e);
    } catch (AlreadyExistsException e) {
      throw new HCatException(
        "AlreadyExistsException while adding partition.", e);
    } catch (MetaException e) {
      throw new HCatException("MetaException while adding partition.", e);
    } catch (NoSuchObjectException e) {
      throw new ObjectNotFoundException("The table " + partInfo.getTableName()
        + " is could not be found.", e);
    } catch (TException e) {
      throw new ConnectionFailureException(
          "TException while adding partition.", e);
    }
  }
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