private boolean validatePartitions(List<Partition> partitions, String dbName, String tableName) throws MetaException {
    Set<List<String>> partitionVals = new HashSet<>();
    // do some basic validation
    for (Partition p : partitions) {
      if (p.getDbName() == null) {
        throw new MetaException("Database for partition cannot be null. " + p.toString());
      }
      if (p.getTableName() == null) {
        throw new MetaException("Table for partition cannot be null. " + p.toString());
      }

      // check that all new partitions are belonging to tables located in the same database
      if (dbName != null && !dbName.equals(p.getDbName())) {
        throw new MetaException("Partition tables doesn't belong to the same database "
            + Arrays.toString(partitions.toArray()));
      } else {
        dbName = p.getDbName();
      }
      // check if all new partitions are part of the same table
      if (tableName != null && !tableName.equals(p.getTableName())) {
        throw new MetaException("New partitions doesn't belong to the same table "
            + Arrays.toString(partitions.toArray()));
      } else {
        tableName = p.getTableName();
      }

      // validate that new partitions belonging to the same table doesn't contain duplicate partition values
      if (!partitionVals.contains(p.getValues())) {
        partitionVals.add(p.getValues());
      } else {
        throw new MetaException("Partition values contains duplicate entries. "
            + Arrays.toString(partitions.toArray()));
      }

      // check if all the tables are tmp tables
      org.apache.hadoop.hive.metastore.api.Table table = getTempTable(p.getDbName(), p.getTableName());
      if (table == null) {
        return false;
      }

      checkPartitionProperties(p);
      // validate partition location
      getPartitionLocation(table, p, false);
    }
    return true;
  }
Validate various partition and table properties (dbName, tableName, partitionValues, table key size).
@param partitions the partition, must be not null
@param dbName name of the database, must be not null
@param tableName name of the table, must be not null
@return true, if all the validation passed. false, if the associated temporary table cannot be found
@throws MetaException some validations can throw it.
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java