use of io.trino.sql.analyzer.RelationType in project trino by trinodb.
the class LogicalPlanner method createOutputPlan.
private PlanNode createOutputPlan(RelationPlan plan, Analysis analysis) {
ImmutableList.Builder<Symbol> outputs = ImmutableList.builder();
ImmutableList.Builder<String> names = ImmutableList.builder();
int columnNumber = 0;
RelationType outputDescriptor = analysis.getOutputDescriptor();
for (Field field : outputDescriptor.getVisibleFields()) {
String name = field.getName().orElse("_col" + columnNumber);
names.add(name);
int fieldIndex = outputDescriptor.indexOf(field);
Symbol symbol = plan.getSymbol(fieldIndex);
outputs.add(symbol);
columnNumber++;
}
return new OutputNode(idAllocator.getNextId(), plan.getRoot(), names.build(), outputs.build());
}
use of io.trino.sql.analyzer.RelationType 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