use of com.facebook.presto.execution.QueryPreparer.PreparedQuery in project presto by prestodb.
the class TestQueryPreparer method testFormattedQuery.
@Test
public void testFormattedQuery() {
Session prepareSession = testSessionBuilder().setSystemProperty(LOG_FORMATTED_QUERY_ENABLED, "true").build();
PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(prepareSession, "PREPARE test FROM SELECT * FROM foo where col1 = ?", WarningCollector.NOOP);
assertEquals(preparedQuery.getFormattedQuery(), Optional.of("-- Formatted Query:\n" + "PREPARE test FROM\n" + " SELECT *\n" + " FROM\n" + " foo\n" + " WHERE (col1 = ?)\n"));
preparedQuery = QUERY_PREPARER.prepareQuery(prepareSession, "PREPARE test FROM SELECT * FROM foo", WarningCollector.NOOP);
assertEquals(preparedQuery.getFormattedQuery(), Optional.of("-- Formatted Query:\n" + "PREPARE test FROM\n" + " SELECT *\n" + " FROM\n" + " foo\n"));
}
use of com.facebook.presto.execution.QueryPreparer.PreparedQuery in project presto by prestodb.
the class TestQueryPreparer method testExecuteStatement.
@Test
public void testExecuteStatement() {
Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT * FROM foo").build();
PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(session, "EXECUTE my_query", WarningCollector.NOOP);
assertEquals(preparedQuery.getStatement(), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo"))));
}
use of com.facebook.presto.execution.QueryPreparer.PreparedQuery in project presto by prestodb.
the class TestQueryPreparer method testSelectStatement.
@Test
public void testSelectStatement() {
PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(TEST_SESSION, "SELECT * FROM foo", WarningCollector.NOOP);
assertEquals(preparedQuery.getStatement(), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo"))));
}
use of com.facebook.presto.execution.QueryPreparer.PreparedQuery in project presto by prestodb.
the class LocalQueryRunner method createPlan.
public Plan createPlan(Session session, @Language("SQL") String sql, List<PlanOptimizer> optimizers, LogicalPlanner.Stage stage, WarningCollector warningCollector) {
Statement wrappedStatement = sqlParser.createStatement(sql, createParsingOptions(session, warningCollector));
PreparedQuery preparedQuery = new QueryPreparer(sqlParser).prepareQuery(session, wrappedStatement, warningCollector);
assertFormattedSql(sqlParser, createParsingOptions(session), preparedQuery.getStatement());
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
QueryExplainer queryExplainer = new QueryExplainer(optimizers, planFragmenter, metadata, accessControl, sqlParser, statsCalculator, costCalculator, dataDefinitionTask, distributedPlanChecker);
Analyzer analyzer = new Analyzer(session, metadata, sqlParser, accessControl, Optional.of(queryExplainer), preparedQuery.getParameters(), warningCollector);
LogicalPlanner logicalPlanner = new LogicalPlanner(wrappedStatement instanceof Explain, session, optimizers, singleNodePlanChecker, idAllocator, metadata, sqlParser, statsCalculator, costCalculator, warningCollector);
Analysis analysis = analyzer.analyze(preparedQuery.getStatement());
return logicalPlanner.plan(analysis, stage);
}
use of com.facebook.presto.execution.QueryPreparer.PreparedQuery in project presto by prestodb.
the class LocalQueryRunner method createPlan.
public Plan createPlan(Session session, @Language("SQL") String sql, LogicalPlanner.Stage stage, boolean forceSingleNode, WarningCollector warningCollector) {
PreparedQuery preparedQuery = new QueryPreparer(sqlParser).prepareQuery(session, sql, warningCollector);
assertFormattedSql(sqlParser, createParsingOptions(session), preparedQuery.getStatement());
return createPlan(session, sql, getPlanOptimizers(forceSingleNode), stage, warningCollector);
}
Aggregations