@Override
    public ListenableFuture<?> execute(CreateFunction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters)
    {
        Map<NodeRef<com.facebook.presto.sql.tree.Parameter>, Expression> parameterLookup = parameterExtractor(statement, parameters);
        Session session = stateMachine.getSession();
        Analyzer analyzer = new Analyzer(session, metadata, sqlParser, accessControl, Optional.empty(), parameters, parameterLookup, stateMachine.getWarningCollector());
        Analysis analysis = analyzer.analyze(statement);
        if (analysis.getFunctionHandles().values().stream()
                .anyMatch(SqlFunctionHandle.class::isInstance)) {
            throw new PrestoException(NOT_SUPPORTED, "Invoking a dynamically registered function in SQL function body is not supported");
        }

        SqlInvokedFunction function = createSqlInvokedFunction(statement, metadata, analysis);
        if (statement.isTemporary()) {
            stateMachine.addSessionFunction(new SqlFunctionId(function.getSignature().getName(), function.getSignature().getArgumentTypes()), function);
        }
        else {
            metadata.getFunctionAndTypeManager().createFunction(function, statement.isReplace());
        }

        return immediateFuture(null);
    }
@Test
    public void testCreateTemporaryFunction()
    {
        SqlParser parser = new SqlParser();
        String sqlString = "CREATE TEMPORARY FUNCTION foo() RETURNS int RETURN 1";
        CreateFunction statement = (CreateFunction) parser.createStatement(sqlString, ParsingOptions.builder().build());
        TransactionManager transactionManager = createTestTransactionManager();
        QueryStateMachine stateMachine = createQueryStateMachine(sqlString, TEST_SESSION, false, transactionManager, executorService, metadataManager);
        new CreateFunctionTask(parser).execute(statement, transactionManager, metadataManager, new AllowAllAccessControl(), stateMachine, emptyList());
        assertEquals(stateMachine.getAddedSessionFunctions().size(), 1);
    }