use of io.trino.sql.planner.plan.ExplainAnalyzeNode in project trino by trinodb.
the class TestVerifyOnlyOneOutputNode method testValidateFailed.
@Test
public void testValidateFailed() {
// random plan with 2 output nodes
PlanNode root = new OutputNode(idAllocator.getNextId(), new ExplainAnalyzeNode(idAllocator.getNextId(), new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new Symbol("a"), ImmutableList.of(), false), ImmutableList.of(), ImmutableList.of());
assertThatThrownBy(() -> new VerifyOnlyOneOutputNode().validate(root, null, PLANNER_CONTEXT, null, null, WarningCollector.NOOP)).isInstanceOf(IllegalStateException.class).hasMessage("Expected plan to have single instance of OutputNode");
}
use of io.trino.sql.planner.plan.ExplainAnalyzeNode in project trino by trinodb.
the class LogicalPlanner method createExplainAnalyzePlan.
private RelationPlan createExplainAnalyzePlan(Analysis analysis, ExplainAnalyze statement) {
RelationPlan underlyingPlan = planStatementWithoutOutput(analysis, statement.getStatement());
PlanNode root = underlyingPlan.getRoot();
Scope scope = analysis.getScope(statement);
Symbol outputSymbol = symbolAllocator.newSymbol(scope.getRelationType().getFieldByIndex(0));
ImmutableList.Builder<Symbol> actualOutputs = ImmutableList.builder();
RelationType outputDescriptor = analysis.getOutputDescriptor(statement.getStatement());
for (Field field : outputDescriptor.getVisibleFields()) {
int fieldIndex = outputDescriptor.indexOf(field);
Symbol symbol = underlyingPlan.getSymbol(fieldIndex);
actualOutputs.add(symbol);
}
root = new ExplainAnalyzeNode(idAllocator.getNextId(), root, outputSymbol, actualOutputs.build(), statement.isVerbose());
return new RelationPlan(root, scope, ImmutableList.of(outputSymbol), Optional.empty());
}
Aggregations