Search in sources :

Example 1 with Prepare

use of io.prestosql.sql.tree.Prepare in project hetu-core by openlookeng.

the class TestPrepareTask method executePrepare.

private Map<String, String> executePrepare(String statementName, Statement statement, String sqlString, Session session) {
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = QueryStateMachine.begin(sqlString, Optional.empty(), session, URI.create("fake://uri"), new ResourceGroupId("test"), new NoOpResourceGroupManager(), false, transactionManager, new AccessControlManager(transactionManager), executor, metadata, WarningCollector.NOOP);
    Prepare prepare = new Prepare(identifier(statementName), statement);
    new PrepareTask(new SqlParser()).execute(prepare, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
    return stateMachine.getAddedPreparedStatements();
}
Also used : AccessControlManager(io.prestosql.security.AccessControlManager) ResourceGroupId(io.prestosql.spi.resourcegroups.ResourceGroupId) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) SqlParser(io.prestosql.sql.parser.SqlParser) Prepare(io.prestosql.sql.tree.Prepare) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager)

Example 2 with Prepare

use of io.prestosql.sql.tree.Prepare in project hetu-core by openlookeng.

the class PrepareTask method execute.

@Override
public ListenableFuture<?> execute(Prepare prepare, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, HeuristicIndexerManager heuristicIndexerManager) {
    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());
    stateMachine.addPreparedStatement(prepare.getName().getValue(), sql);
    return immediateFuture(null);
}
Also used : Execute(io.prestosql.sql.tree.Execute) Deallocate(io.prestosql.sql.tree.Deallocate) Statement(io.prestosql.sql.tree.Statement) Prepare(io.prestosql.sql.tree.Prepare) PrestoException(io.prestosql.spi.PrestoException)

Aggregations

Prepare (io.prestosql.sql.tree.Prepare)2 NoOpResourceGroupManager (io.prestosql.execution.resourcegroups.NoOpResourceGroupManager)1 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)1 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)1 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)1 AccessControlManager (io.prestosql.security.AccessControlManager)1 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)1 PrestoException (io.prestosql.spi.PrestoException)1 ResourceGroupId (io.prestosql.spi.resourcegroups.ResourceGroupId)1 SqlParser (io.prestosql.sql.parser.SqlParser)1 Deallocate (io.prestosql.sql.tree.Deallocate)1 Execute (io.prestosql.sql.tree.Execute)1 Statement (io.prestosql.sql.tree.Statement)1 InMemoryTransactionManager.createTestTransactionManager (io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager)1 TransactionManager (io.prestosql.transaction.TransactionManager)1