presto-main/src/main/java/io/prestosql/execution/UseTask.java/UseTask/execute
class UseTask:    @Override
    public ListenableFuture<?> execute(Use statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters)
    {
        Session session = stateMachine.getSession();

        if (!statement.getCatalog().isPresent() && !session.getCatalog().isPresent()) {
            throw semanticException(MISSING_CATALOG_NAME, statement, "Catalog must be specified when session catalog is not set");
        }

        if (statement.getCatalog().isPresent()) {
            String catalog = statement.getCatalog().get().getValue().toLowerCase(ENGLISH);
            if (!metadata.getCatalogHandle(session, catalog).isPresent()) {
                throw new PrestoException(NOT_FOUND, "Catalog does not exist: " + catalog);
            }
            stateMachine.setSetCatalog(catalog);
        }

        stateMachine.setSetSchema(statement.getSchema().getValue().toLowerCase(ENGLISH));

        return immediateFuture(null);
    }