Search in sources :

Example 1 with QueryPreparer

use of io.trino.execution.QueryPreparer in project trino by trinodb.

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);
    assertFormattedSql(sqlParser, createParsingOptions(session), preparedQuery.getStatement());
    return createPlan(session, sql, getPlanOptimizers(forceSingleNode), stage, warningCollector);
}
Also used : QueryPreparer(io.trino.execution.QueryPreparer) PreparedQuery(io.trino.execution.QueryPreparer.PreparedQuery)

Example 2 with QueryPreparer

use of io.trino.execution.QueryPreparer in project trino by trinodb.

the class LocalQueryRunner method createPlan.

public Plan createPlan(Session session, @Language("SQL") String sql, List<PlanOptimizer> optimizers, LogicalPlanner.Stage stage, WarningCollector warningCollector) {
    PreparedQuery preparedQuery = new QueryPreparer(sqlParser).prepareQuery(session, sql);
    assertFormattedSql(sqlParser, createParsingOptions(session), preparedQuery.getStatement());
    PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
    AnalyzerFactory analyzerFactory = createAnalyzerFactory(createQueryExplainerFactory(optimizers));
    Analyzer analyzer = analyzerFactory.createAnalyzer(session, preparedQuery.getParameters(), parameterExtractor(preparedQuery.getStatement(), preparedQuery.getParameters()), warningCollector);
    LogicalPlanner logicalPlanner = new LogicalPlanner(session, optimizers, new PlanSanityChecker(true), idAllocator, getPlannerContext(), new TypeAnalyzer(plannerContext, statementAnalyzerFactory), statsCalculator, costCalculator, warningCollector);
    Analysis analysis = analyzer.analyze(preparedQuery.getStatement());
    // make LocalQueryRunner always compute plan statistics for test purposes
    return logicalPlanner.plan(analysis, stage);
}
Also used : QueryPreparer(io.trino.execution.QueryPreparer) LogicalPlanner(io.trino.sql.planner.LogicalPlanner) PlanNodeIdAllocator(io.trino.sql.planner.PlanNodeIdAllocator) Analysis(io.trino.sql.analyzer.Analysis) PreparedQuery(io.trino.execution.QueryPreparer.PreparedQuery) PlanSanityChecker(io.trino.sql.planner.sanity.PlanSanityChecker) Analyzer(io.trino.sql.analyzer.Analyzer) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) AnalyzerFactory(io.trino.sql.analyzer.AnalyzerFactory)

Aggregations

QueryPreparer (io.trino.execution.QueryPreparer)2 PreparedQuery (io.trino.execution.QueryPreparer.PreparedQuery)2 Analysis (io.trino.sql.analyzer.Analysis)1 Analyzer (io.trino.sql.analyzer.Analyzer)1 AnalyzerFactory (io.trino.sql.analyzer.AnalyzerFactory)1 StatementAnalyzerFactory (io.trino.sql.analyzer.StatementAnalyzerFactory)1 LogicalPlanner (io.trino.sql.planner.LogicalPlanner)1 PlanNodeIdAllocator (io.trino.sql.planner.PlanNodeIdAllocator)1 TypeAnalyzer (io.trino.sql.planner.TypeAnalyzer)1 PlanSanityChecker (io.trino.sql.planner.sanity.PlanSanityChecker)1