Search in sources :

Example 1 with TransactionalMetadata

use of com.facebook.presto.hive.TransactionalMetadata in project presto by prestodb.

the class LegacyAccessControl method checkCanDropTable.

@Override
public void checkCanDropTable(ConnectorTransactionHandle transaction, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName) {
    if (!allowDropTable) {
        denyDropTable(tableName.toString());
    }
    TransactionalMetadata metadata = hiveTransactionManager.get(transaction);
    // TODO: Refactor code to inject metastore headers using AccessControlContext instead of empty()
    MetastoreContext metastoreContext = new MetastoreContext(identity, context.getQueryId().getId(), context.getClientInfo(), context.getSource(), Optional.empty(), false, HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER);
    Optional<Table> target = metadata.getMetastore().getTable(metastoreContext, tableName.getSchemaName(), tableName.getTableName());
    if (!target.isPresent()) {
        denyDropTable(tableName.toString(), "Table not found");
    }
    if (!identity.getUser().equals(target.get().getOwner())) {
        denyDropTable(tableName.toString(), "Owner of the table is different from session user");
    }
}
Also used : Table(com.facebook.presto.hive.metastore.Table) AccessDeniedException.denyDropTable(com.facebook.presto.spi.security.AccessDeniedException.denyDropTable) AccessDeniedException.denyRenameTable(com.facebook.presto.spi.security.AccessDeniedException.denyRenameTable) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) TransactionalMetadata(com.facebook.presto.hive.TransactionalMetadata)

Aggregations

TransactionalMetadata (com.facebook.presto.hive.TransactionalMetadata)1 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)1 Table (com.facebook.presto.hive.metastore.Table)1 AccessDeniedException.denyDropTable (com.facebook.presto.spi.security.AccessDeniedException.denyDropTable)1 AccessDeniedException.denyRenameTable (com.facebook.presto.spi.security.AccessDeniedException.denyRenameTable)1