Search in sources :

Example 6 with Explain

use of com.facebook.presto.sql.tree.Explain 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);
}
Also used : QueryPreparer(com.facebook.presto.execution.QueryPreparer) QueryExplainer(com.facebook.presto.sql.analyzer.QueryExplainer) LogicalPlanner(com.facebook.presto.sql.planner.LogicalPlanner) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) Statement(com.facebook.presto.sql.tree.Statement) Analysis(com.facebook.presto.sql.analyzer.Analysis) Explain(com.facebook.presto.sql.tree.Explain) PreparedQuery(com.facebook.presto.execution.QueryPreparer.PreparedQuery) Analyzer(com.facebook.presto.sql.analyzer.Analyzer)

Example 7 with Explain

use of com.facebook.presto.sql.tree.Explain in project presto by prestodb.

the class ExplainVerification method getQueryRewrite.

@Override
protected QueryBundle getQueryRewrite(ClusterType clusterType) {
    Statement statement = sqlParser.createStatement(getSourceQuery().getQuery(clusterType), PARSING_OPTIONS);
    Explain explain = new Explain(statement, false, false, ImmutableList.of(new ExplainFormat(JSON)));
    return new QueryBundle(ImmutableList.of(), explain, ImmutableList.of(), clusterType);
}
Also used : ExplainFormat(com.facebook.presto.sql.tree.ExplainFormat) Statement(com.facebook.presto.sql.tree.Statement) Explain(com.facebook.presto.sql.tree.Explain)

Aggregations

Explain (com.facebook.presto.sql.tree.Explain)7 Statement (com.facebook.presto.sql.tree.Statement)4 PrestoException (com.facebook.presto.spi.PrestoException)2 LogicalPlanner (com.facebook.presto.sql.planner.LogicalPlanner)2 Execute (com.facebook.presto.sql.tree.Execute)2 ExplainFormat (com.facebook.presto.sql.tree.ExplainFormat)2 Expression (com.facebook.presto.sql.tree.Expression)2 Test (org.testng.annotations.Test)2 Session (com.facebook.presto.Session)1 QueryPreparer (com.facebook.presto.execution.QueryPreparer)1 PreparedQuery (com.facebook.presto.execution.QueryPreparer.PreparedQuery)1 SqlQueryExecutionFactory (com.facebook.presto.execution.SqlQueryExecution.SqlQueryExecutionFactory)1 QueryQueueFullException (com.facebook.presto.execution.resourceGroups.QueryQueueFullException)1 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)1 QueryId (com.facebook.presto.spi.QueryId)1 PlanNodeIdAllocator (com.facebook.presto.spi.plan.PlanNodeIdAllocator)1 QueryType (com.facebook.presto.spi.resourceGroups.QueryType)1 QueryUtil.quotedIdentifier (com.facebook.presto.sql.QueryUtil.quotedIdentifier)1 Analysis (com.facebook.presto.sql.analyzer.Analysis)1 Analyzer (com.facebook.presto.sql.analyzer.Analyzer)1