Example usage for com.amazonaws.services.glue.model GetPartitionsRequest GetPartitionsRequest

List of usage examples for com.amazonaws.services.glue.model GetPartitionsRequest GetPartitionsRequest

Introduction

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

Prototype

GetPartitionsRequest

Source Link

Usage

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

License:Apache License

private List<Partition> getPartitions(String databaseName, String tableName, String expression) {
    try {/*from  w w  w .j  a va 2 s. c om*/
        List<Partition> partitions = new ArrayList<>();
        String nextToken = null;

        do {
            GetPartitionsResult result = glueClient
                    .getPartitions(new GetPartitionsRequest().withDatabaseName(databaseName)
                            .withTableName(tableName).withExpression(expression).withNextToken(nextToken));
            result.getPartitions()
                    .forEach(partition -> partitions.add(GlueToPrestoConverter.convertPartition(partition)));
            nextToken = result.getNextToken();
        } while (nextToken != null);

        return partitions;
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}