Search in sources :

Example 1 with Deallocate

use of com.facebook.presto.sql.tree.Deallocate in project presto by prestodb.

the class TestDeallocateTask method executeDeallocate.

private Set<String> executeDeallocate(String statementName, String sqlString, Session session) {
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, transactionManager, executor, metadata);
    Deallocate deallocate = new Deallocate(new Identifier(statementName));
    DeallocateTask deallocateTask = new DeallocateTask();
    deallocateTask.execute(deallocate, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList());
    return stateMachine.getDeallocatedPreparedStatements();
}
Also used : TaskTestUtils.createQueryStateMachine(com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine) Identifier(com.facebook.presto.sql.tree.Identifier) Deallocate(com.facebook.presto.sql.tree.Deallocate) InMemoryTransactionManager.createTestTransactionManager(com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager) TransactionManager(com.facebook.presto.transaction.TransactionManager) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl)

Example 2 with Deallocate

use of com.facebook.presto.sql.tree.Deallocate in project presto by prestodb.

the class PrepareTask method execute.

@Override
public ListenableFuture<?> execute(Prepare prepare, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine queryStateMachine, List<Expression> parameters) {
    Statement statement = prepare.getStatement();
    if ((statement instanceof Prepare) || (statement instanceof Execute) || (statement instanceof Deallocate)) {
        String type = statement.getClass().getSimpleName().toUpperCase(ENGLISH);
        throw new PrestoException(NOT_SUPPORTED, "Invalid statement type for prepared statement: " + type);
    }
    String sql = getFormattedSql(statement, sqlParser, Optional.empty());
    queryStateMachine.addPreparedStatement(prepare.getName().getValue(), sql);
    return immediateFuture(null);
}
Also used : Execute(com.facebook.presto.sql.tree.Execute) Deallocate(com.facebook.presto.sql.tree.Deallocate) Statement(com.facebook.presto.sql.tree.Statement) Prepare(com.facebook.presto.sql.tree.Prepare) PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

Deallocate (com.facebook.presto.sql.tree.Deallocate)2 TaskTestUtils.createQueryStateMachine (com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine)1 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)1 PrestoException (com.facebook.presto.spi.PrestoException)1 Execute (com.facebook.presto.sql.tree.Execute)1 Identifier (com.facebook.presto.sql.tree.Identifier)1 Prepare (com.facebook.presto.sql.tree.Prepare)1 Statement (com.facebook.presto.sql.tree.Statement)1 InMemoryTransactionManager.createTestTransactionManager (com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager)1 TransactionManager (com.facebook.presto.transaction.TransactionManager)1