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

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

Introduction

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

Prototype

DeletePartitionRequest

Source Link

Usage

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

License:Apache License

@Override
public void dropPartition(String databaseName, String tableName, List<String> parts, boolean deleteData) {
    Table table = getTableOrElseThrow(databaseName, tableName);
    Partition partition = getPartition(databaseName, tableName, parts).orElseThrow(
            () -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), parts));

    try {/*from   w w w  .  j a v  a 2  s . c  o m*/
        glueClient.deletePartition(new DeletePartitionRequest().withDatabaseName(databaseName)
                .withTableName(tableName).withPartitionValues(parts));
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }

    String partLocation = partition.getStorage().getLocation();
    if (deleteData && isManagedTable(table) && !isNullOrEmpty(partLocation)) {
        deleteDir(hdfsContext, hdfsEnvironment, new Path(partLocation), true);
    }
}