use of io.prestosql.sql.planner.plan.OutputNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateSuccessful.
@Test
public void testValidateSuccessful() {
// random seemingly valid plan
PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.sql.planner.plan.OutputNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateFailed.
@Test(expectedExceptions = IllegalStateException.class)
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"), false), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.sql.planner.plan.OutputNode in project hetu-core by openlookeng.
the class SqlQueryExecution method handleCrossRegionDynamicFilter.
private void handleCrossRegionDynamicFilter(PlanRoot plan) {
if (!isCrossRegionDynamicFilterEnabled(getSession()) || plan == null) {
return;
}
StateStore stateStore = stateStoreProvider.getStateStore();
if (stateStore == null) {
return;
}
String queryId = getSession().getQueryId().getId();
log.debug("queryId=%s begin to find columnToColumnMapping.", queryId);
PlanNode outputNode = plan.getRoot().getFragment().getRoot();
Map<String, Set<String>> columnToSymbolMapping = new HashMap<>();
if (outputNode != null && outputNode instanceof OutputNode) {
List<String> queryColumnNames = ((OutputNode) outputNode).getColumnNames();
List<Symbol> outputSymbols = outputNode.getOutputSymbols();
Map<String, Set<String>> tmpMapping = new HashMap<>(outputSymbols.size());
for (Symbol symbol : outputNode.getOutputSymbols()) {
Set<String> sets = new HashSet();
sets.add(symbol.getName());
tmpMapping.put(symbol.getName(), sets);
}
for (PlanFragment fragment : plan.getRoot().getAllFragments()) {
if ("0".equals(fragment.getId().toString())) {
continue;
}
PlanNode sourceNode = fragment.getRoot();
findMappingFromPlan(tmpMapping, sourceNode);
}
for (int i = 0; i < outputSymbols.size(); i++) {
columnToSymbolMapping.put(queryColumnNames.get(i), tmpMapping.get(outputSymbols.get(i).getName()));
}
}
// save mapping into stateStore
StateMap<String, Object> mappingStateMap = (StateMap<String, Object>) stateStore.getOrCreateStateCollection(CROSS_REGION_DYNAMIC_FILTERS, StateCollection.Type.MAP);
mappingStateMap.put(queryId + QUERY_COLUMN_NAME_TO_SYMBOL_MAPPING, columnToSymbolMapping);
log.debug("queryId=%s, add columnToSymbolMapping into hazelcast success.", queryId + QUERY_COLUMN_NAME_TO_SYMBOL_MAPPING);
}
use of io.prestosql.sql.planner.plan.OutputNode in project hetu-core by openlookeng.
the class LogicalPlanner method planStatement.
public PlanNode planStatement(Analysis analysis, Statement statement) {
if ((statement instanceof CreateTableAsSelect) && analysis.isCreateTableAsSelectNoOp()) {
checkState(analysis.getCreateTableDestination().isPresent(), "Table destination is missing");
Symbol symbol = planSymbolAllocator.newSymbol("rows", BIGINT);
PlanNode source = new ValuesNode(idAllocator.getNextId(), ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(new ConstantExpression(0L, BIGINT))));
return new OutputNode(idAllocator.getNextId(), source, ImmutableList.of("rows"), ImmutableList.of(symbol));
}
return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis);
}
use of io.prestosql.sql.planner.plan.OutputNode in project hetu-core by openlookeng.
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());
}
Aggregations