Search in sources :

Example 1 with DeleteTableRequest

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

the class GlueHiveMetastore method dropTable.

@Override
public void dropTable(MetastoreContext metastoreContext, String databaseName, String tableName, boolean deleteData) {
    Table table = getTableOrElseThrow(metastoreContext, databaseName, tableName);
    try {
        stats.getDeleteTable().record(() -> glueClient.deleteTable(new DeleteTableRequest().withCatalogId(catalogId).withDatabaseName(databaseName).withName(tableName)));
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
    String tableLocation = table.getStorage().getLocation();
    if (deleteData && isManagedTable(table) && !isNullOrEmpty(tableLocation)) {
        deleteDir(hdfsContext, hdfsEnvironment, new Path(tableLocation), true);
    }
}
Also used : DeleteTableRequest(com.amazonaws.services.glue.model.DeleteTableRequest) Path(org.apache.hadoop.fs.Path) Table(com.facebook.presto.hive.metastore.Table) AmazonServiceException(com.amazonaws.AmazonServiceException) PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

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