@Test
  public void testTopKConsumeAllChildrenPipelineBuilder3() throws IllegalPathException {
    TypeProvider typeProvider = new TypeProvider();
    TopKNode topKNode = initTopKNode(typeProvider, 4);
    LocalExecutionPlanContext context = createLocalExecutionPlanContext(typeProvider);
    context.setDegreeOfParallelism(3);

    List<Operator> childrenOperator =
        operatorTreeGenerator.dealWithConsumeAllChildrenPipelineBreaker(topKNode, context);
    // The number of pipeline is 2, since parent pipeline hasn't joined
    assertEquals(2, context.getPipelineNumber());

    // Validate the first pipeline
    assertEquals(3, childrenOperator.size());
    assertEquals(SingleDeviceViewOperator.class, childrenOperator.get(0).getClass());
    assertEquals(ExchangeOperator.class, childrenOperator.get(1).getClass());
    assertEquals(ExchangeOperator.class, childrenOperator.get(2).getClass());

    // Validate the changes of node structure
    assertEquals(3, topKNode.getChildren().size());
    assertEquals("Time", topKNode.getChildren().get(0).getOutputColumnNames().get(0));
    assertEquals("Time", topKNode.getChildren().get(1).getOutputColumnNames().get(0));
    assertEquals("Time", topKNode.getChildren().get(2).getOutputColumnNames().get(0));
    assertEquals(TopKNode.class, topKNode.getChildren().get(2).getClass());

    // Validate the second pipeline
    ExchangeOperator exchangeOperator1 = (ExchangeOperator) childrenOperator.get(1);
    assertEquals("SingleDeviceViewNode1", exchangeOperator1.getSourceId().getId());

    // Validate the third pipeline
    TopKNode subTimeJoinNode = (TopKNode) topKNode.getChildren().get(2);
    assertEquals(2, subTimeJoinNode.getChildren().size());
    assertEquals("Time", subTimeJoinNode.getChildren().get(0).getOutputColumnNames().get(0));
    assertEquals("Time", subTimeJoinNode.getChildren().get(1).getOutputColumnNames().get(0));
    ExchangeOperator exchangeOperator2 = (ExchangeOperator) childrenOperator.get(2);
    assertEquals(exchangeOperator2.getSourceId(), subTimeJoinNode.getPlanNodeId());

    // Validate the number exchange operator
    assertEquals(2, context.getExchangeSumNum());
  }
This test will test dop = 3. Expected result is three pipelines:

<p>The first is: TopKNode1 - [SingleDeviceViewNode0, ExchangeOperator, ExchangeOperator];

<p>The second is: ExchangeOperator - SingleDeviceViewNode1.

<p>The third is: ExchangeOperator - TopKNode1-1[SingleDeviceViewNode2, SingleDeviceViewNode3].
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/PipelineBuilderTest.java