Search in sources :

Example 1 with HiveViewNotSupportedException

use of io.trino.plugin.hive.HiveViewNotSupportedException in project trino by trinodb.

the class SqlStandardAccessControlMetadata method listTablePrivileges.

@Override
public List<GrantInfo> listTablePrivileges(ConnectorSession session, List<SchemaTableName> tableNames) {
    Set<HivePrincipal> principals = ThriftMetastoreUtil.listEnabledPrincipals(session.getIdentity(), metastore::listRoleGrants).collect(toImmutableSet());
    boolean isAdminRoleSet = hasAdminRole(principals);
    ImmutableList.Builder<GrantInfo> result = ImmutableList.builder();
    for (SchemaTableName tableName : tableNames) {
        try {
            result.addAll(buildGrants(principals, isAdminRoleSet, tableName));
        } catch (TableNotFoundException e) {
        // table disappeared during listing operation
        } catch (HiveViewNotSupportedException e) {
        // table is an unsupported hive view but shouldn't fail listTablePrivileges.
        }
    }
    return result.build();
}
Also used : TableNotFoundException(io.trino.spi.connector.TableNotFoundException) HivePrincipal(io.trino.plugin.hive.metastore.HivePrincipal) ImmutableList(com.google.common.collect.ImmutableList) GrantInfo(io.trino.spi.security.GrantInfo) SchemaTableName(io.trino.spi.connector.SchemaTableName) HiveViewNotSupportedException(io.trino.plugin.hive.HiveViewNotSupportedException)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 HiveViewNotSupportedException (io.trino.plugin.hive.HiveViewNotSupportedException)1 HivePrincipal (io.trino.plugin.hive.metastore.HivePrincipal)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1 TableNotFoundException (io.trino.spi.connector.TableNotFoundException)1 GrantInfo (io.trino.spi.security.GrantInfo)1