private void createAndSetLocationForAddedPartition(Partition partition, Path partitionLocation) throws MetaException {

    if (partitionLocation != null) {
      partition.getSd().setLocation(partitionLocation.toString());

      // Check to see if the directory already exists before calling
      // mkdirs() because if the file system is read-only, mkdirs will
      // throw an exception even if the directory already exists.
      if (!getWh().isDir(partitionLocation)) {
        if (!getWh().mkdirs(partitionLocation)) {
          throw new MetaException(partitionLocation
              + " is not a directory or unable to create one");
        }
      }
    }
  }
Create the directory for partition and set it to the partition.

@param partition         instance of the partition, must be not null
@param partitionLocation the location of the partition
@throws MetaException if the target directory already exists
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java