public void addPartitions(List<MPartition> parts, List<List<MPartitionPrivilege>> partPrivilegesList,
      List<List<MPartitionColumnPrivilege>> partColPrivilegesList) throws MetaException {
    Map<Long, MSerDeInfo> serdeIdToSerDeInfo = new HashMap<>();
    Map<Long, MColumnDescriptor> cdIdToColumnDescriptor = new HashMap<>();
    Map<Long, MStorageDescriptor> sdIdToStorageDescriptor = new HashMap<>();
    Map<Long, MPartition> partIdToPartition = new HashMap<>();
    Map<Long, MPartitionPrivilege> partGrantIdToPrivilege = new HashMap<>();
    Map<Long, MPartitionColumnPrivilege> partColumnGrantIdToPrivilege = new HashMap<>();
    Map<Long, Long> sdIdToSerdeId = new HashMap<>();
    Map<Long, Long> sdIdToCdId = new HashMap<>();
    Map<Long, Long> partIdToSdId = new HashMap<>();
    Map<Long, List<String>> stringListIdToStringList = new HashMap<>();
    Map<Long, Long> stringListIdToSdId = new HashMap<>();
    Map<Long, String> stringListIdToLocation = new HashMap<>();
    Map<Long, Long> partGrantIdToPartId = new HashMap<>();
    Map<Long, Long> partColumnGrantIdToPartId = new HashMap<>();
    List<Long> stringListIds = new ArrayList<>();
    int partitionsCount = parts.size();
    for (int index = 0; index < partitionsCount; index++) {
      MPartition part = parts.get(index);
      MStorageDescriptor sd = part.getSd();
      if (part.getValues() == null || sd == null || sd.getSerDeInfo() == null || sd.getCD() == null
          || sd.getCD().getCols() == null) {
        throw new MetaException("Invalid partition");
      }
      Long serDeId = getDataStoreId(MSerDeInfo.class);
      serdeIdToSerDeInfo.put(serDeId, sd.getSerDeInfo());

      Long cdId;
      LongIdentity storeId = (LongIdentity) pm.getObjectId(sd.getCD());
      if (storeId == null) {
        cdId = getDataStoreId(MColumnDescriptor.class);
        cdIdToColumnDescriptor.put(cdId, sd.getCD());
      } else {
        cdId = (Long) storeId.getKeyAsObject();
      }

      Long sdId = getDataStoreId(MStorageDescriptor.class);
      sdIdToStorageDescriptor.put(sdId, sd);
      sdIdToSerdeId.put(sdId, serDeId);
      sdIdToCdId.put(sdId, cdId);

      Long partId = getDataStoreId(MPartition.class);
      partIdToPartition.put(partId, part);
      partIdToSdId.put(partId, sdId);

      Map<List<String>, String> stringListToLocation = new HashMap<>();
      if (sd.getSkewedColValueLocationMaps() != null) {
        for (Map.Entry<MStringList, String> entry : sd.getSkewedColValueLocationMaps().entrySet()) {
          stringListToLocation.put(entry.getKey().getInternalList(), entry.getValue());
        }
      }
      if (CollectionUtils.isNotEmpty(sd.getSkewedColValues())) {
        int skewedValCount = sd.getSkewedColValues().size();
        for (int i = 0; i < skewedValCount; i++) {
          Long stringListId = getDataStoreId(MStringList.class);
          stringListIds.add(stringListId);
          stringListIdToSdId.put(stringListId, sdId);
          List<String> stringList = sd.getSkewedColValues().get(i).getInternalList();
          stringListIdToStringList.put(stringListId, stringList);
          String location = stringListToLocation.get(stringList);
          if (location != null) {
            stringListIdToLocation.put(stringListId, location);
          }
        }
      }

      List<MPartitionPrivilege> partPrivileges = partPrivilegesList.get(index);
      for (MPartitionPrivilege partPrivilege : partPrivileges) {
        Long partGrantId = getDataStoreId(MPartitionPrivilege.class);
        partGrantIdToPrivilege.put(partGrantId, partPrivilege);
        partGrantIdToPartId.put(partGrantId, partId);
      }
      List<MPartitionColumnPrivilege> partColPrivileges = partColPrivilegesList.get(index);
      for (MPartitionColumnPrivilege partColPrivilege : partColPrivileges) {
        Long partColumnGrantId = getDataStoreId(MPartitionColumnPrivilege.class);
        partColumnGrantIdToPrivilege.put(partColumnGrantId, partColPrivilege);
        partColumnGrantIdToPartId.put(partColumnGrantId, partId);
      }
    }
    insertSerdeInBatch(serdeIdToSerDeInfo);
    insertSerdeParamInBatch(serdeIdToSerDeInfo);
    insertColumnDescriptorInBatch(cdIdToColumnDescriptor);
    insertColumnV2InBatch(cdIdToColumnDescriptor);
    insertStorageDescriptorInBatch(sdIdToStorageDescriptor, sdIdToSerdeId, sdIdToCdId);
    insertStorageDescriptorParamInBatch(sdIdToStorageDescriptor);
    insertBucketColInBatch(sdIdToStorageDescriptor);
    insertSortColInBatch(sdIdToStorageDescriptor);
    insertSkewedColInBatch(sdIdToStorageDescriptor);
    insertSkewedStringListInBatch(stringListIds);
    insertSkewedStringListValInBatch(stringListIdToStringList);
    insertSkewedValInBatch(stringListIds, stringListIdToSdId);
    insertSkewedLocationInBatch(stringListIdToLocation, stringListIdToSdId);
    insertPartitionInBatch(partIdToPartition, partIdToSdId);
    insertPartitionParamInBatch(partIdToPartition);
    insertPartitionKeyValInBatch(partIdToPartition);
    insertPartitionPrivilegeInBatch(partGrantIdToPrivilege, partGrantIdToPartId);
    insertPartitionColPrivilegeInBatch(partColumnGrantIdToPrivilege, partColumnGrantIdToPartId);
  }
Add partitions in batch using direct SQL
@param parts list of partitions
@param partPrivilegesList list of partition privileges
@param partColPrivilegesList list of partition column privileges
@throws MetaException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlInsertPart.java