public static String printDistributed(SubPlan plan, FunctionAndTypeManager functionAndTypeManager, Session session)
    {
        List<PlanFragment> fragments = plan.getAllFragments();
        Map<PlanFragmentId, PlanFragment> fragmentsById = Maps.uniqueIndex(fragments, PlanFragment::getId);
        PlanNodeIdGenerator idGenerator = new PlanNodeIdGenerator();

        StringBuilder output = new StringBuilder();
        output.append("digraph distributed_plan {\n");

        printSubPlan(plan, fragmentsById, idGenerator, output, functionAndTypeManager, session);

        output.append("}\n");

        return output.toString();
    }
@Test
    public void testPrintDistributed()
    {
        SubPlan tableScanNodeSubPlan = new SubPlan(
                createTestPlanFragment(0, TEST_TABLE_SCAN_NODE),
                ImmutableList.of());
        SubPlan nestedSubPlan = new SubPlan(
                createTestPlanFragment(1, TEST_TABLE_SCAN_NODE),
                ImmutableList.of(tableScanNodeSubPlan));
        String actualNestedSubPlan = printDistributed(
                nestedSubPlan,
                FUNCTION_AND_TYPE_MANAGER,
                testSessionBuilder().build());
        String expectedNestedSubPlan = join(
                System.lineSeparator(),
                "digraph distributed_plan {",
                "subgraph cluster_1 {",
                "label = \"SOURCE\"",
                format("plannode_1[%s];", TEST_TABLE_SCAN_NODE_INNER_OUTPUT),
                "}",
                "subgraph cluster_0 {",
                "label = \"SOURCE\"",
                format("plannode_1[%s];", TEST_TABLE_SCAN_NODE_INNER_OUTPUT),
                "}",
                "}",
                "");
        assertEquals(actualNestedSubPlan, expectedNestedSubPlan);
    }