use of io.trino.sql.planner.PlanFragment in project trino by trinodb.
the class TestDynamicFilterService method createPlan.
private static PlanFragment createPlan(DynamicFilterId consumedDynamicFilterId, DynamicFilterId producedDynamicFilterId, PartitioningHandle stagePartitioning, ExchangeNode.Type exchangeType) {
Symbol symbol = new Symbol("column");
Symbol buildSymbol = new Symbol("buildColumn");
PlanNodeId tableScanNodeId = new PlanNodeId("plan_id");
TableScanNode tableScan = TableScanNode.newInstance(tableScanNodeId, TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")), false, Optional.empty());
FilterNode filterNode = new FilterNode(new PlanNodeId("filter_node_id"), tableScan, createDynamicFilterExpression(session, createTestMetadataManager(), consumedDynamicFilterId, VARCHAR, symbol.toSymbolReference()));
RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("remote_id"), new PlanFragmentId("plan_fragment_id"), ImmutableList.of(buildSymbol), Optional.empty(), exchangeType, RetryPolicy.NONE);
return new PlanFragment(new PlanFragmentId("plan_id"), new JoinNode(new PlanNodeId("join_id"), INNER, filterNode, remote, ImmutableList.of(), tableScan.getOutputSymbols(), remote.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(producedDynamicFilterId, buildSymbol), Optional.empty()), ImmutableMap.of(symbol, VARCHAR), stagePartitioning, ImmutableList.of(tableScanNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty());
}
use of io.trino.sql.planner.PlanFragment in project trino by trinodb.
the class QueryMonitor method extractPlanNodeStats.
private static void extractPlanNodeStats(StageInfo stageInfo, ImmutableMultimap.Builder<FragmentNode, OperatorStats> planNodeStats) {
PlanFragment fragment = stageInfo.getPlan();
if (fragment == null) {
return;
}
// Note: a plan node may be mapped to multiple operators
Map<PlanNodeId, Collection<OperatorStats>> allOperatorStats = Multimaps.index(stageInfo.getStageStats().getOperatorSummaries(), OperatorStats::getPlanNodeId).asMap();
// Sometimes a plan node is merged with other nodes into a single operator, and in that case,
// use the stats of the nearest parent node with stats.
fragment.getRoot().accept(new PlanVisitor<Void, Collection<OperatorStats>>() {
@Override
protected Void visitPlan(PlanNode node, Collection<OperatorStats> parentStats) {
Collection<OperatorStats> operatorStats = allOperatorStats.getOrDefault(node.getId(), parentStats);
planNodeStats.putAll(new FragmentNode(fragment.getId(), node.getId()), operatorStats);
for (PlanNode child : node.getSources()) {
child.accept(this, operatorStats);
}
return null;
}
}, ImmutableList.of());
}
use of io.trino.sql.planner.PlanFragment in project trino by trinodb.
the class StatsAndCosts method reconstructStatsAndCosts.
private static void reconstructStatsAndCosts(StageInfo stage, ImmutableMap.Builder<PlanNodeId, PlanNodeStatsEstimate> planNodeStats, ImmutableMap.Builder<PlanNodeId, PlanCostEstimate> planNodeCosts) {
PlanFragment planFragment = stage.getPlan();
if (planFragment != null) {
planNodeStats.putAll(planFragment.getStatsAndCosts().getStats());
planNodeCosts.putAll(planFragment.getStatsAndCosts().getCosts());
}
for (StageInfo subStage : stage.getSubStages()) {
reconstructStatsAndCosts(subStage, planNodeStats, planNodeCosts);
}
}
use of io.trino.sql.planner.PlanFragment in project trino by trinodb.
the class GraphvizPrinter method printSubPlan.
private static void printSubPlan(SubPlan plan, Map<PlanFragmentId, PlanFragment> fragmentsById, PlanNodeIdGenerator idGenerator, StringBuilder output) {
PlanFragment fragment = plan.getFragment();
printFragmentNodes(output, fragment, idGenerator);
fragment.getRoot().accept(new EdgePrinter(output, fragmentsById, idGenerator), null);
for (SubPlan child : plan.getChildren()) {
printSubPlan(child, fragmentsById, idGenerator, output);
}
}
use of io.trino.sql.planner.PlanFragment in project trino by trinodb.
the class TestLegacyPhasedExecutionSchedule method testBroadcastJoin.
@Test
public void testBroadcastJoin() {
PlanFragment buildFragment = createTableScanPlanFragment("build");
PlanFragment joinFragment = createBroadcastJoinPlanFragment("join", buildFragment);
List<Set<PlanFragmentId>> phases = LegacyPhasedExecutionSchedule.extractPhases(ImmutableList.of(joinFragment, buildFragment));
assertEquals(phases, ImmutableList.of(ImmutableSet.of(joinFragment.getId(), buildFragment.getId())));
}
Aggregations