private boolean validatePartition(final Partition part, final String catName,
                                    final String tblName, final String dbName, final Set<PartValEqWrapperLite> partsToAdd,
                                    final RawStore ms, final boolean ifNotExists, List<FieldSchema> partitionKeys) throws MetaException, TException {

    if (part.getDbName() == null || part.getTableName() == null) {
      throw new MetaException("The database and table name must be set in the partition.");
    }

    if (!part.getTableName().equalsIgnoreCase(tblName)
        || !part.getDbName().equalsIgnoreCase(dbName)) {
      String errorMsg = String.format(
          "Partition does not belong to target table %s. It belongs to the table %s.%s : %s",
          TableName.getQualified(catName, dbName, tblName), part.getDbName(),
          part.getTableName(), part.toString());
      throw new MetaException(errorMsg);
    }

    if (part.getValues() == null || part.getValues().isEmpty()) {
      throw new MetaException("The partition values cannot be null or empty.");
    }

    if (part.getValues().contains(null)) {
      throw new MetaException("Partition value cannot be null.");
    }

    boolean shouldAdd = startAddPartition(ms, part, partitionKeys, ifNotExists);
    if (!shouldAdd) {
      LOG.info("Not adding partition {} as it already exists", part);
      return false;
    }

    if (!partsToAdd.add(new PartValEqWrapperLite(part))) {
      // Technically, for ifNotExists case, we could insert one and discard the other
      // because the first one now "exists", but it seems better to report the problem
      // upstream as such a command doesn't make sense.
      throw new MetaException("Duplicate partitions in the list: " + part);
    }
    return true;
  }
Validate a partition before creating it. The validation checks
<ul>
<li>if the database and table names set in the partition are not null and they are matching
with the expected values set in the tblName and dbName parameters.</li>
<li>if the partition values are set.</li>
<li>if none of the partition values is null.</li>
<li>if the partition values are matching with the pattern set in the
'metastore.partition.name.whitelist.pattern' configuration property.</li>
<li>if the partition doesn't already exist. If the partition already exists, an exception
will be thrown if the ifNotExists parameter is false, otherwise it will be just ignored.</li>
<li>if the partsToAdd set doesn't contain the partition. The partsToAdd set contains the
partitions which are already validated. If the set contains the current partition, it means
that the partition is tried to be added multiple times in the same batch. Please note that
the set will be updated with the current partition if the validation was successful.</li>
</ul>
@param part
@param catName
@param tblName
@param dbName
@param partsToAdd
@param ms
@param ifNotExists
@return
@throws MetaException
@throws TException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java