private static PartitionSpec getSharedSDPartSpec(Table table, StorageDescriptorKey sdKey, List<PartitionWithoutSD> partitions) {
    StorageDescriptor sd;
    if (sdKey.getSd() == null) {
      //sd is not requested set it empty StorageDescriptor in the PartitionSpec
      sd = new StorageDescriptor();
    } else {
      sd = new StorageDescriptor(sdKey.getSd());
      sd.setLocation(sdKey.baseLocation); // Use table-dir as root-dir.
    }
    PartitionSpecWithSharedSD sharedSDPartSpec =
        new PartitionSpecWithSharedSD();
    sharedSDPartSpec.setPartitions(partitions);
    sharedSDPartSpec.setSd(sd);

    PartitionSpec ret = new PartitionSpec();
    ret.setRootPath(sd.getLocation());
    ret.setSharedSDPartitionSpec(sharedSDPartSpec);
    ret.setDbName(table.getDbName());
    ret.setTableName(table.getTableName());
    ret.setCatName(table.getCatName());

    return ret;
  }
Convert list of partitions to a PartitionSpec object.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java