public void addPartitionsToTable()

in xtable-hive-metastore/src/main/java/org/apache/xtable/hms/HMSCatalogPartitionSyncOperations.java [75:110]


  public void addPartitionsToTable(
      CatalogTableIdentifier catalogTableIdentifier, List<CatalogPartition> partitionsToAdd) {
    HierarchicalTableIdentifier tableIdentifier =
        toHierarchicalTableIdentifier(catalogTableIdentifier);
    if (partitionsToAdd.isEmpty()) {
      log.info("No partitions to add for {}", tableIdentifier);
      return;
    }
    log.info("Adding partitions {} to table {}", partitionsToAdd.size(), tableIdentifier);
    try {
      StorageDescriptor sd =
          metaStoreClient
              .getTable(tableIdentifier.getDatabaseName(), tableIdentifier.getTableName())
              .getSd();

      CollectionUtils.batches(partitionsToAdd, catalogConfig.getMaxPartitionsPerRequest())
          .forEach(
              batch -> {
                List<Partition> partitionList = new ArrayList<>();
                batch.forEach(
                    partition -> {
                      partitionList.add(createPartition(tableIdentifier, partition, sd));
                    });
                try {
                  metaStoreClient.add_partitions(partitionList, true, false);
                } catch (TException e) {
                  log.error("{} add partition failed", tableIdentifier, e);
                  throw new CatalogSyncException(tableIdentifier + " add partition failed", e);
                }
                log.info("Add batch partitions done: {}", partitionList.size());
              });
    } catch (TException e) {
      log.error("Failed to add partitions to table {}", tableIdentifier, e);
      throw new CatalogSyncException(tableIdentifier + " add partition failed", e);
    }
  }