private Path getPartitionLocation(org.apache.hadoop.hive.metastore.api.Table table, Partition partition,
      boolean forceOverwrite)
      throws MetaException {
    Path partLocation = null;
    String partLocationStr = null;
    if (partition.getSd() != null) {
      partLocationStr = partition.getSd().getLocation();
    }
    if (partLocationStr == null || partLocationStr.isEmpty() || forceOverwrite) {
      // set default location if not specified and this is
      // a physical table partition (not a view)
      if (table.getSd().getLocation() != null) {
        partLocation =
            new Path(table.getSd().getLocation(), makePartName(table.getPartitionKeys(), partition.getValues()));
      }
    } else {
      if (table.getSd().getLocation() == null) {
        throw new MetaException("Cannot specify location for a view partition");
      }
      try {
        partLocation = getWh().getDnsPath(new Path(partLocationStr));
      } catch (IllegalArgumentException e) {
        throw new MetaException("Partition path is invalid. " + e.getLocalizedMessage());
      }
    }
    return partLocation;
  }
Get the partition location. If the partition location is not set the location of the parent table will be used.

@param table     the parent table, must be not null
@param partition instance of the partition, must be not null
@param forceOverwrite force recalculation of location based on table/partition name
@return location of partition
@throws MetaException if the partition location cannot be specified or the location is invalid.
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java