public void dropPartitions()

in xtable-aws/src/main/java/org/apache/xtable/glue/GlueCatalogPartitionSyncOperations.java [210:256]


  public void dropPartitions(
      CatalogTableIdentifier catalogTableIdentifier, List<CatalogPartition> partitionsToDrop) {
    HierarchicalTableIdentifier tableIdentifier =
        toHierarchicalTableIdentifier(catalogTableIdentifier);
    if (isNullOrEmpty(partitionsToDrop)) {
      log.info("No partitions to drop for {}", tableIdentifier);
      return;
    }
    log.info("Drop {} CatalogPartition(s) in table {}", partitionsToDrop.size(), tableIdentifier);
    try {
      List<BatchDeletePartitionResponse> responses = new ArrayList<>();

      CollectionUtils.batches(partitionsToDrop, glueCatalogConfig.getMaxPartitionsPerRequest())
          .forEach(
              batch -> {
                List<PartitionValueList> partitionValueLists =
                    batch.stream()
                        .map(
                            CatalogPartition ->
                                PartitionValueList.builder()
                                    .values(CatalogPartition.getValues())
                                    .build())
                        .collect(Collectors.toList());

                BatchDeletePartitionRequest batchDeletePartitionRequest =
                    BatchDeletePartitionRequest.builder()
                        .databaseName(tableIdentifier.getDatabaseName())
                        .tableName(tableIdentifier.getTableName())
                        .partitionsToDelete(partitionValueLists)
                        .build();
                responses.add(glueClient.batchDeletePartition(batchDeletePartitionRequest));
              });

      responses.forEach(
          response -> {
            if (CollectionUtils.nonEmpty(response.errors())) {
              throw new CatalogSyncException(
                  "Fail to drop partitions to "
                      + tableIdentifier
                      + " with error(s): "
                      + response.errors());
            }
          });
    } catch (Exception e) {
      throw new CatalogSyncException("Fail to drop partitions to " + tableIdentifier, e);
    }
  }