Search in sources :

Example 1 with InputExtractor

use of com.facebook.presto.sql.planner.InputExtractor in project presto by prestodb.

the class SqlQueryExecution method doAnalyzeQuery.

private PlanRoot doAnalyzeQuery() {
    // time analysis phase
    long analysisStart = System.nanoTime();
    // analyze query
    Analyzer analyzer = new Analyzer(stateMachine.getSession(), metadata, sqlParser, accessControl, Optional.of(queryExplainer), parameters);
    Analysis analysis = analyzer.analyze(statement);
    stateMachine.setUpdateType(analysis.getUpdateType());
    // plan query
    PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
    LogicalPlanner logicalPlanner = new LogicalPlanner(stateMachine.getSession(), planOptimizers, idAllocator, metadata, sqlParser);
    Plan plan = logicalPlanner.plan(analysis);
    // extract inputs
    List<Input> inputs = new InputExtractor(metadata, stateMachine.getSession()).extractInputs(plan.getRoot());
    stateMachine.setInputs(inputs);
    // extract output
    Optional<Output> output = new OutputExtractor().extractOutput(plan.getRoot());
    stateMachine.setOutput(output);
    // fragment the plan
    SubPlan subplan = PlanFragmenter.createSubPlans(stateMachine.getSession(), metadata, plan);
    // record analysis time
    stateMachine.recordAnalysisTime(analysisStart);
    boolean explainAnalyze = analysis.getStatement() instanceof Explain && ((Explain) analysis.getStatement()).isAnalyze();
    return new PlanRoot(subplan, !explainAnalyze, extractConnectors(analysis));
}
Also used : LogicalPlanner(com.facebook.presto.sql.planner.LogicalPlanner) Explain(com.facebook.presto.sql.tree.Explain) InputExtractor(com.facebook.presto.sql.planner.InputExtractor) Analyzer(com.facebook.presto.sql.analyzer.Analyzer) StageExecutionPlan(com.facebook.presto.sql.planner.StageExecutionPlan) Plan(com.facebook.presto.sql.planner.Plan) SubPlan(com.facebook.presto.sql.planner.SubPlan) OutputExtractor(com.facebook.presto.sql.planner.OutputExtractor) PlanNodeIdAllocator(com.facebook.presto.sql.planner.PlanNodeIdAllocator) Analysis(com.facebook.presto.sql.analyzer.Analysis) SubPlan(com.facebook.presto.sql.planner.SubPlan)

Aggregations

Analysis (com.facebook.presto.sql.analyzer.Analysis)1 Analyzer (com.facebook.presto.sql.analyzer.Analyzer)1 InputExtractor (com.facebook.presto.sql.planner.InputExtractor)1 LogicalPlanner (com.facebook.presto.sql.planner.LogicalPlanner)1 OutputExtractor (com.facebook.presto.sql.planner.OutputExtractor)1 Plan (com.facebook.presto.sql.planner.Plan)1 PlanNodeIdAllocator (com.facebook.presto.sql.planner.PlanNodeIdAllocator)1 StageExecutionPlan (com.facebook.presto.sql.planner.StageExecutionPlan)1 SubPlan (com.facebook.presto.sql.planner.SubPlan)1 Explain (com.facebook.presto.sql.tree.Explain)1