@Test
  public void testOrderByTime2() throws Exception {
    TreeTopKOperator topKOperator = topKOperatorTest(Ordering.ASC, Ordering.DESC, limitValue);
    long lastTime = -1;
    int checkDevice = 0;
    int count = 0;
    while (topKOperator.isBlocked().isDone() && topKOperator.hasNext()) {
      TsBlock tsBlock = topKOperator.next();
      if (tsBlock == null) {
        continue;
      }
      assertEquals(6, tsBlock.getValueColumnCount());
      count += tsBlock.getPositionCount();
      for (int i = 0; i < tsBlock.getPositionCount(); i++) {
        assertTrue(tsBlock.getTimeByIndex(i) >= lastTime);
        lastTime = tsBlock.getTimeByIndex(i);
        if (Objects.equals(tsBlock.getColumn(0).getBinary(i).toString(), DEVICE2)) {
          assertTrue(tsBlock.getColumn(1).isNull(i));
          assertTrue(tsBlock.getColumn(2).isNull(i));
          assertTrue(tsBlock.getColumn(3).isNull(i));
          assertEquals(getValue(lastTime), tsBlock.getColumn(4).getInt(i));
          assertEquals(getValue(lastTime), tsBlock.getColumn(5).getInt(i));
          assertEquals(0, checkDevice);
          checkDevice++;
        } else if (Objects.equals(tsBlock.getColumn(0).getBinary(i).toString(), DEVICE1)) {
          assertTrue(tsBlock.getColumn(1).isNull(i));
          assertTrue(tsBlock.getColumn(4).isNull(i));
          assertTrue(tsBlock.getColumn(5).isNull(i));
          assertEquals(getValue(lastTime), tsBlock.getColumn(2).getInt(i));
          assertEquals(getValue(lastTime), tsBlock.getColumn(3).getInt(i));
          assertEquals(1, checkDevice);
          checkDevice++;
        } else if (Objects.equals(tsBlock.getColumn(0).getBinary(i).toString(), DEVICE0)) {
          assertTrue(tsBlock.getColumn(2).isNull(i));
          assertTrue(tsBlock.getColumn(3).isNull(i));
          assertTrue(tsBlock.getColumn(4).isNull(i));
          assertTrue(tsBlock.getColumn(5).isNull(i));
          assertEquals(getValue(lastTime), tsBlock.getColumn(1).getInt(i));
          // make sure the device column is by desc
          assertEquals(2, checkDevice);
          checkDevice = 0;
        } else {
          fail();
        }
      }
    }

    assertEquals(limitValue, count);
  }
The original data and structure of this test is same as {@link MergeTreeSortOperatorTest}.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/TreeTopKOperatorTest.java