Search in sources :

Example 1 with SCHEMA_NOT_FOUND

use of io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND in project trino by trinodb.

the class SetSchemaAuthorizationTask method execute.

@Override
public ListenableFuture<Void> execute(SetSchemaAuthorization statement, QueryStateMachine stateMachine, List<Expression> parameters, WarningCollector warningCollector) {
    Session session = stateMachine.getSession();
    CatalogSchemaName source = createCatalogSchemaName(session, statement, Optional.of(statement.getSource()));
    if (!metadata.schemaExists(session, source)) {
        throw semanticException(SCHEMA_NOT_FOUND, statement, "Schema '%s' does not exist", source);
    }
    TrinoPrincipal principal = createPrincipal(statement.getPrincipal());
    checkRoleExists(session, statement, metadata, principal, Optional.of(source.getCatalogName()).filter(catalog -> metadata.isCatalogManagedSecurity(session, catalog)));
    accessControl.checkCanSetSchemaAuthorization(session.toSecurityContext(), source, principal);
    metadata.setSchemaAuthorization(session, source, principal);
    return immediateVoidFuture();
}
Also used : Futures.immediateVoidFuture(com.google.common.util.concurrent.Futures.immediateVoidFuture) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MetadataUtil.checkRoleExists(io.trino.metadata.MetadataUtil.checkRoleExists) Inject(javax.inject.Inject) List(java.util.List) AccessControl(io.trino.security.AccessControl) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) MetadataUtil.createPrincipal(io.trino.metadata.MetadataUtil.createPrincipal) Objects.requireNonNull(java.util.Objects.requireNonNull) WarningCollector(io.trino.execution.warnings.WarningCollector) CatalogSchemaName(io.trino.spi.connector.CatalogSchemaName) Metadata(io.trino.metadata.Metadata) SetSchemaAuthorization(io.trino.sql.tree.SetSchemaAuthorization) Optional(java.util.Optional) Expression(io.trino.sql.tree.Expression) MetadataUtil.createCatalogSchemaName(io.trino.metadata.MetadataUtil.createCatalogSchemaName) SemanticExceptions.semanticException(io.trino.sql.analyzer.SemanticExceptions.semanticException) Session(io.trino.Session) SCHEMA_NOT_FOUND(io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND) CatalogSchemaName(io.trino.spi.connector.CatalogSchemaName) MetadataUtil.createCatalogSchemaName(io.trino.metadata.MetadataUtil.createCatalogSchemaName) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) Session(io.trino.Session)

Aggregations

Futures.immediateVoidFuture (com.google.common.util.concurrent.Futures.immediateVoidFuture)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Session (io.trino.Session)1 WarningCollector (io.trino.execution.warnings.WarningCollector)1 Metadata (io.trino.metadata.Metadata)1 MetadataUtil.checkRoleExists (io.trino.metadata.MetadataUtil.checkRoleExists)1 MetadataUtil.createCatalogSchemaName (io.trino.metadata.MetadataUtil.createCatalogSchemaName)1 MetadataUtil.createPrincipal (io.trino.metadata.MetadataUtil.createPrincipal)1 AccessControl (io.trino.security.AccessControl)1 SCHEMA_NOT_FOUND (io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND)1 CatalogSchemaName (io.trino.spi.connector.CatalogSchemaName)1 TrinoPrincipal (io.trino.spi.security.TrinoPrincipal)1 SemanticExceptions.semanticException (io.trino.sql.analyzer.SemanticExceptions.semanticException)1 Expression (io.trino.sql.tree.Expression)1 SetSchemaAuthorization (io.trino.sql.tree.SetSchemaAuthorization)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1