Example usage for com.amazonaws.services.glue.model BatchCreatePartitionResult getErrors

List of usage examples for com.amazonaws.services.glue.model BatchCreatePartitionResult getErrors

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model BatchCreatePartitionResult getErrors.

Prototype


public java.util.List<PartitionError> getErrors() 

Source Link

Document

The errors encountered when trying to create the requested partitions.

Usage

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions) {
    try {/*ww  w. jav  a  2s .  c om*/
        List<List<PartitionWithStatistics>> batchedPartitions = Lists.partition(partitions,
                BATCH_CREATE_PARTITION_MAX_PAGE_SIZE);
        List<Future<BatchCreatePartitionResult>> futures = new ArrayList<>();

        for (List<PartitionWithStatistics> partitionBatch : batchedPartitions) {
            List<PartitionInput> partitionInputs = partitionBatch.stream()
                    .map(GlueInputConverter::convertPartition).collect(toList());
            futures.add(glueClient
                    .batchCreatePartitionAsync(new BatchCreatePartitionRequest().withDatabaseName(databaseName)
                            .withTableName(tableName).withPartitionInputList(partitionInputs)));
        }

        for (Future<BatchCreatePartitionResult> future : futures) {
            BatchCreatePartitionResult result = future.get();
            propagatePartitionErrorToPrestoException(databaseName, tableName, result.getErrors());
        }
    } catch (AmazonServiceException | InterruptedException | ExecutionException e) {
        if (e instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        }
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}