### Question:
SchedulingOrderVisitor { public static List<PlanNodeId> scheduleOrder(PlanNode root) { ImmutableList.Builder<PlanNodeId> schedulingOrder = ImmutableList.builder(); root.accept(new Visitor(schedulingOrder::add), null); return schedulingOrder.build(); } private  SchedulingOrderVisitor(); static List<PlanNodeId> scheduleOrder(PlanNode root);  }### Answer:
@Test public void testJoinOrder() { PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata()); TableScanNode a = planBuilder.tableScan(emptyList(), emptyMap()); TableScanNode b = planBuilder.tableScan(emptyList(), emptyMap()); List<PlanNodeId> order = scheduleOrder(planBuilder.join(JoinNode.Type.INNER, a, b)); assertEquals(order, ImmutableList.of(b.getId(), a.getId())); }
@Test public void testIndexJoinOrder() { PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata()); TableScanNode a = planBuilder.tableScan(emptyList(), emptyMap()); TableScanNode b = planBuilder.tableScan(emptyList(), emptyMap()); List<PlanNodeId> order = scheduleOrder(planBuilder.indexJoin(IndexJoinNode.Type.INNER, a, b)); assertEquals(order, ImmutableList.of(b.getId(), a.getId())); }
@Test public void testSemiJoinOrder() { PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata()); Symbol sourceJoin = planBuilder.symbol("sourceJoin"); TableScanNode a = planBuilder.tableScan(ImmutableList.of(sourceJoin), ImmutableMap.of(sourceJoin, new TestingColumnHandle("sourceJoin"))); Symbol filteringSource = planBuilder.symbol("filteringSource"); TableScanNode b = planBuilder.tableScan(ImmutableList.of(filteringSource), ImmutableMap.of(filteringSource, new TestingColumnHandle("filteringSource"))); List<PlanNodeId> order = scheduleOrder(planBuilder.semiJoin( sourceJoin, filteringSource, planBuilder.symbol("semiJoinOutput"), Optional.empty(), Optional.empty(), a, b)); assertEquals(order, ImmutableList.of(b.getId(), a.getId())); }