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();
}
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);
}
Aggregations