private void updateSkewedInfoInBatch(Map<Long, SkewedInfo> sdIdToSkewedInfo,
                                       List<Long> sdIds) throws MetaException {
    // Delete all mapping old stringLists and skewedValues,
    // skewedValues first for the foreign key constraint.
    List<Long> stringListId = getStringListId(sdIds);
    if (!stringListId.isEmpty()) {
      Batchable.runBatched(maxBatchSize, sdIds, new Batchable<Long, Void>() {
        @Override
        public List<Void> run(List<Long> input) throws Exception {
          String idLists = MetaStoreDirectSql.getIdListForIn(input);
          String deleteSkewValuesQuery =
              "delete from \"SKEWED_VALUES\" where \"SD_ID_OID\" in (" + idLists + ")";
          updateWithStatement(PreparedStatement::executeUpdate, deleteSkewValuesQuery);
          String deleteSkewColValueLocMapQuery =
              "delete from \"SKEWED_COL_VALUE_LOC_MAP\" where \"SD_ID\" in (" + idLists + ")";
          updateWithStatement(PreparedStatement::executeUpdate, deleteSkewColValueLocMapQuery);
          String deleteSkewColNamesQuery =
              "delete from \"SKEWED_COL_NAMES\" where \"SD_ID\" in (" + idLists + ")";
          updateWithStatement(PreparedStatement::executeUpdate, deleteSkewColNamesQuery);
          return null;
        }
      });
      Batchable.runBatched(maxBatchSize, stringListId, new Batchable<Long, Void>() {
        @Override
        public List<Void> run(List<Long> input) throws MetaException {
          String idLists = MetaStoreDirectSql.getIdListForIn(input);
          String deleteStringListValuesQuery =
              "delete from \"SKEWED_STRING_LIST_VALUES\" where \"STRING_LIST_ID\" in (" + idLists + ")";
          updateWithStatement(PreparedStatement::executeUpdate, deleteStringListValuesQuery);
          String deleteStringListQuery =
              "delete from \"SKEWED_STRING_LIST\" where \"STRING_LIST_ID\" in (" + idLists + ")";
          updateWithStatement(PreparedStatement::executeUpdate, deleteStringListQuery);
          return null;
        }
      });
    }

    // Generate new stringListId for each SdId
    Map<Long, List<String>> idToSkewedColNames = new HashMap<>();         // used for SKEWED_COL_NAMES
    List<Long> newStringListId = new ArrayList<>();                       // used for SKEWED_STRING_LIST
    Map<Long, List<String>> stringListIdToValues = new HashMap<>();       // used for SKEWED_STRING_LIST_VALUES
    Map<Long, List<Long>> sdIdToNewStringListId = new HashMap<>();        // used for SKEWED_VALUES
    Map<Long, List<Pair<Long, String>>> sdIdToValueLoc = new HashMap<>(); // used for SKEWED_COL_VALUE_LOC_MAP

    List<Long> idWithSkewedInfo = filterIdsByNonNullValue(sdIds, sdIdToSkewedInfo);
    for (Long sdId : idWithSkewedInfo) {
      SkewedInfo skewedInfo = sdIdToSkewedInfo.get(sdId);
      idToSkewedColNames.put(sdId, skewedInfo.getSkewedColNames());
      List<List<String>> skewedColValues = skewedInfo.getSkewedColValues();
      if (skewedColValues != null) {
        for (List<String> colValues : skewedColValues) {
          Long nextStringListId = getDataStoreId(MStringList.class);
          newStringListId.add(nextStringListId);
          sdIdToNewStringListId.computeIfAbsent(sdId, k -> new ArrayList<>()).add(nextStringListId);
          stringListIdToValues.put(nextStringListId, colValues);
        }
      }
      Map<List<String>, String> skewedColValueLocationMaps = skewedInfo.getSkewedColValueLocationMaps();
      if (skewedColValueLocationMaps != null) {
        for (Map.Entry<List<String>, String> entry : skewedColValueLocationMaps.entrySet()) {
          List<String> colValues = entry.getKey();
          String location = entry.getValue();
          Long nextStringListId = getDataStoreId(MStringList.class);
          newStringListId.add(nextStringListId);
          stringListIdToValues.put(nextStringListId, colValues);
          sdIdToValueLoc.computeIfAbsent(sdId, k -> new ArrayList<>()).add(Pair.of(nextStringListId, location));
        }
      }
    }

    insertSkewedColNamesInBatch(idToSkewedColNames, sdIds);
    insertStringListInBatch(newStringListId);
    insertStringListValuesInBatch(stringListIdToValues, newStringListId);
    insertSkewedValuesInBatch(sdIdToNewStringListId, sdIds);
    insertSkewColValueLocInBatch(sdIdToValueLoc, sdIds);
  }
Gets the next CS id from sequence MPartitionColumnStatistics and increment the CS id by numStats.
@return The CD id before update.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java