@Test
  public void groupByTimeRawDataTest3() throws Exception {
    int[][] result =
        new int[][] {
          {100, 100, 100, 99},
          {2004950, 2014950, 624950, 834551},
          {0, 100, 200, 300},
          {99, 199, 299, 398},
          {20099, 20199, 10259, 10379},
          {20000, 20100, 260, 380},
          {20000, 20100, 10200, 10300},
          {20099, 20199, 299, 398}
        };
    List<TAggregationType> aggregationTypes = new ArrayList<>();
    List<List<InputLocation[]>> inputLocations = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
      aggregationTypes.add(TAggregationType.COUNT);
      aggregationTypes.add(TAggregationType.SUM);
      aggregationTypes.add(TAggregationType.MIN_TIME);
      aggregationTypes.add(TAggregationType.MAX_TIME);
      aggregationTypes.add(TAggregationType.MAX_VALUE);
      aggregationTypes.add(TAggregationType.MIN_VALUE);
      aggregationTypes.add(TAggregationType.FIRST_VALUE);
      aggregationTypes.add(TAggregationType.LAST_VALUE);
      for (int j = 0; j < 8; j++) {
        List<InputLocation[]> inputLocationForOneAggregator = new ArrayList<>();
        inputLocationForOneAggregator.add(new InputLocation[] {new InputLocation(0, i)});
        inputLocations.add(inputLocationForOneAggregator);
      }
    }
    GroupByTimeParameter groupByTimeParameter =
        new GroupByTimeParameter(0, 399, new TimeDuration(0, 100), new TimeDuration(0, 100), true);

    WindowParameter windowParameter = new TimeWindowParameter(true);
    RawDataAggregationOperator rawDataAggregationOperator =
        initRawDataAggregationOperator(
            aggregationTypes, groupByTimeParameter, inputLocations, windowParameter);
    int count = 0;

    while (rawDataAggregationOperator.isBlocked().isDone()
        && rawDataAggregationOperator.hasNext()) {
      TsBlock resultTsBlock = rawDataAggregationOperator.next();
      if (resultTsBlock == null) {
        continue;
      }

      for (int row = 0; row < resultTsBlock.getPositionCount(); row++, count++) {
        assertEquals(100 * count, resultTsBlock.getTimeColumn().getLong(row));
        // endTime
        long endTime = 100L * count + 99;
        if (count == 3) {
          endTime = 398;
        }
        assertEquals(endTime, resultTsBlock.getColumn(0).getLong(row));
        for (int i = 0; i < 2; i++) {
          assertEquals(result[0][count], resultTsBlock.getColumn(8 * i + 1).getLong(row));
          assertEquals(result[1][count], resultTsBlock.getColumn(8 * i + 2).getDouble(row), 0.0001);
          assertEquals(result[2][count], resultTsBlock.getColumn(8 * i + 3).getLong(row));
          assertEquals(result[3][count], resultTsBlock.getColumn(8 * i + 4).getLong(row));
          assertEquals(result[4][count], resultTsBlock.getColumn(8 * i + 5).getInt(row));
          assertEquals(result[5][count], resultTsBlock.getColumn(8 * i + 6).getInt(row));
          assertEquals(result[6][count], resultTsBlock.getColumn(8 * i + 7).getInt(row));
          assertEquals(result[7][count], resultTsBlock.getColumn(8 * i + 8).getInt(row));
        }
      }
    }

    assertEquals(4, count);
  }
Test by time interval with EndTime
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/RawDataAggregationOperatorTest.java