Search in sources :

Example 1 with DeletePartitionRequest

use of com.amazonaws.services.glue.model.DeletePartitionRequest in project presto by prestodb.

the class GlueHiveMetastore method dropPartition.

@Override
public void dropPartition(MetastoreContext metastoreContext, String databaseName, String tableName, List<String> parts, boolean deleteData) {
    Table table = getTableOrElseThrow(metastoreContext, databaseName, tableName);
    Partition partition = getPartition(metastoreContext, databaseName, tableName, parts).orElseThrow(() -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), parts));
    try {
        stats.getDeletePartition().record(() -> glueClient.deletePartition(new DeletePartitionRequest().withCatalogId(catalogId).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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Partition(com.facebook.presto.hive.metastore.Partition) PartitionNotFoundException(com.facebook.presto.hive.PartitionNotFoundException) Table(com.facebook.presto.hive.metastore.Table) AmazonServiceException(com.amazonaws.AmazonServiceException) DeletePartitionRequest(com.amazonaws.services.glue.model.DeletePartitionRequest) PrestoException(com.facebook.presto.spi.PrestoException) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)1 DeletePartitionRequest (com.amazonaws.services.glue.model.DeletePartitionRequest)1 PartitionNotFoundException (com.facebook.presto.hive.PartitionNotFoundException)1 Partition (com.facebook.presto.hive.metastore.Partition)1 Table (com.facebook.presto.hive.metastore.Table)1 PrestoException (com.facebook.presto.spi.PrestoException)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1 Path (org.apache.hadoop.fs.Path)1