@Override
  public AddPartitionsResult add_partitions_req(AddPartitionsRequest request)
      throws TException {
    startFunction("add_partitions_req",
        ": db=" + request.getDbName() + " tab=" + request.getTblName());
    AddPartitionsResult result = new AddPartitionsResult();
    if (request.getParts().isEmpty()) {
      return result;
    }
    String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
    String dbName = request.getDbName();
    String tblName = request.getTblName();
    startTableFunction("add_partitions_req", catName, dbName, tblName);

    Exception ex = null;
    try {
      if (!request.isSetCatName()) {
        request.setCatName(catName);
      }
      boolean isColSkippedForPartitions = request.isSkipColumnSchemaForPartition();
      // Make sure all the partitions have the catalog set as well
      request.getParts().forEach(p -> p.setCatName(catName));
      List<Partition> parts = add_partitions_core(getMS(),catName, dbName, tblName,
          request.getParts(), request.isIfNotExists(),
          request.isSkipColumnSchemaForPartition(), request.getEnvironmentContext());
      if (request.isNeedResult()) {
        if (isColSkippedForPartitions) {
          if (!parts.isEmpty()) {
            StorageDescriptor sd = parts.get(0).getSd().deepCopy();
            result.setPartitionColSchema(sd.getCols());
          }
          parts.stream().forEach(partition -> partition.getSd().getCols().clear());
        }
        result.setPartitions(parts);
      }
    } catch (Exception e) {
      ex = e;
      throw handleException(e).throwIfInstance(TException.class).defaultMetaException();
    } finally {
      endFunction("add_partitions_req", ex == null, ex, tblName);
    }
    return result;
  }
Create the location folders for the partitions. For each partition a separate thread will be
started to create the folder. The method will wait until all threads are finished and returns
the partitions whose folders were created successfully. If an error occurs during the
execution of a thread, a MetaException will be thrown.
@param partitionsToAdd
@param table
@param addedPartitions
@return
@throws MetaException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java