private static void fixLocationInPartSpec(ImportTableDesc tblDesc, Table table,
      Warehouse wh, ReplicationSpec replicationSpec, AlterTableAddPartitionDesc.PartitionDesc partSpec,
      EximUtil.SemanticAnalyzerWrapperContext x) throws MetaException, HiveException, IOException {
    if (externalTablePartition(tblDesc, replicationSpec)) {
      /*
        we use isExternal and not tableType() method since that always gives type as managed table.
        we don't do anything since for external table partitions the path is already set correctly
        in {@link org.apache.hadoop.hive.ql.parse.repl.load.message.TableHandler}
       */
      return;
    }
    Path tableLocation = getTableDataLocation(wh, table, tblDesc, x);
    Path tgtPath = new Path(tableLocation, Warehouse.makePartPath(partSpec.getPartSpec()));
    FileSystem tgtFs = FileSystem.get(tgtPath.toUri(), x.getConf());
    checkTargetLocationEmpty(tgtFs, tgtPath, replicationSpec, x.getLOG());
    partSpec.setLocation(tgtPath.toString());
  }
Helper method to set location properly in partSpec
ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java