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");
}
}
Aggregations