Search in sources :

Example 1 with ExplainAnalyzeNode

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

the class TestVerifyOnlyOneOutputNode method testValidateFailed.

@Test(expectedExceptions = IllegalStateException.class)
public void testValidateFailed() {
    // random plan with 2 output nodes
    PlanNode root = new OutputNode(Optional.empty(), idAllocator.getNextId(), new ExplainAnalyzeNode(Optional.empty(), idAllocator.getNextId(), new OutputNode(Optional.empty(), idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(Optional.empty(), idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new VariableReferenceExpression(Optional.empty(), "a", BIGINT), false), ImmutableList.of(), ImmutableList.of());
    new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
Also used : ValuesNode(com.facebook.presto.spi.plan.ValuesNode) OutputNode(com.facebook.presto.sql.planner.plan.OutputNode) PlanNode(com.facebook.presto.spi.plan.PlanNode) ExplainAnalyzeNode(com.facebook.presto.sql.planner.plan.ExplainAnalyzeNode) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) ProjectNode(com.facebook.presto.spi.plan.ProjectNode) Test(org.testng.annotations.Test)

Example 2 with ExplainAnalyzeNode

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

the class LogicalPlanner method createExplainAnalyzePlan.

private RelationPlan createExplainAnalyzePlan(Analysis analysis, Explain statement) {
    RelationPlan underlyingPlan = planStatementWithoutOutput(analysis, statement.getStatement());
    PlanNode root = underlyingPlan.getRoot();
    Scope scope = analysis.getScope(statement);
    VariableReferenceExpression outputVariable = variableAllocator.newVariable(scope.getRelationType().getFieldByIndex(0));
    root = new ExplainAnalyzeNode(getSourceLocation(statement), idAllocator.getNextId(), root, outputVariable, statement.isVerbose());
    return new RelationPlan(root, scope, ImmutableList.of(outputVariable));
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) Scope(com.facebook.presto.sql.analyzer.Scope) ExplainAnalyzeNode(com.facebook.presto.sql.planner.plan.ExplainAnalyzeNode) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression)

Aggregations

PlanNode (com.facebook.presto.spi.plan.PlanNode)2 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)2 ExplainAnalyzeNode (com.facebook.presto.sql.planner.plan.ExplainAnalyzeNode)2 ProjectNode (com.facebook.presto.spi.plan.ProjectNode)1 ValuesNode (com.facebook.presto.spi.plan.ValuesNode)1 Scope (com.facebook.presto.sql.analyzer.Scope)1 OutputNode (com.facebook.presto.sql.planner.plan.OutputNode)1 Test (org.testng.annotations.Test)1