private AggregationOperator initAggregationOperator(
      List<TAggregationType> aggregationTypes,
      GroupByTimeParameter groupByTimeParameter,
      List<List<InputLocation[]>> inputLocations)
      throws IllegalPathException {
    // Construct operator tree
    QueryId queryId = new QueryId("stub_query");
    FragmentInstanceId instanceId =
        new FragmentInstanceId(new PlanFragmentId(queryId, 0), "stub-instance");
    FragmentInstanceStateMachine stateMachine =
        new FragmentInstanceStateMachine(instanceId, instanceNotificationExecutor);
    FragmentInstanceContext fragmentInstanceContext =
        createFragmentInstanceContext(instanceId, stateMachine);
    DriverContext driverContext = new DriverContext(fragmentInstanceContext, 0);
    PlanNodeId planNodeId1 = new PlanNodeId("1");
    driverContext.addOperatorContext(
        1, planNodeId1, SeriesAggregationScanOperator.class.getSimpleName());
    PlanNodeId planNodeId2 = new PlanNodeId("2");
    driverContext.addOperatorContext(
        2, planNodeId2, SeriesAggregationScanOperator.class.getSimpleName());
    PlanNodeId planNodeId3 = new PlanNodeId("3");
    driverContext.addOperatorContext(3, planNodeId3, AggregationOperator.class.getSimpleName());
    driverContext
        .getOperatorContexts()
        .forEach(operatorContext -> OperatorContext.setMaxRunTime(TEST_TIME_SLICE));

    NonAlignedFullPath measurementPath1 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(AGGREGATION_OPERATOR_TEST_SG + ".device0"),
            new MeasurementSchema("sensor0", TSDataType.INT32));
    List<TreeAggregator> aggregators = new ArrayList<>();
    AccumulatorFactory.createBuiltinAccumulators(
            aggregationTypes,
            TSDataType.INT32,
            Collections.emptyList(),
            Collections.emptyMap(),
            true)
        .forEach(o -> aggregators.add(new TreeAggregator(o, AggregationStep.PARTIAL)));

    SeriesScanOptions.Builder scanOptionsBuilder = new SeriesScanOptions.Builder();
    scanOptionsBuilder.withAllSensors(Collections.singleton("sensor0"));
    SeriesAggregationScanOperator seriesAggregationScanOperator1 =
        new SeriesAggregationScanOperator(
            planNodeId1,
            measurementPath1,
            Ordering.ASC,
            scanOptionsBuilder.build(),
            driverContext.getOperatorContexts().get(0),
            aggregators,
            initTimeRangeIterator(groupByTimeParameter, true, true, ZoneId.systemDefault()),
            groupByTimeParameter,
            DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES,
            true);

    List<TsFileResource> seqResources1 = new ArrayList<>();
    List<TsFileResource> unSeqResources1 = new ArrayList<>();
    seqResources1.add(seqResources.get(0));
    seqResources1.add(seqResources.get(1));
    seqResources1.add(seqResources.get(3));
    unSeqResources1.add(unSeqResources.get(0));
    unSeqResources1.add(unSeqResources.get(1));
    unSeqResources1.add(unSeqResources.get(3));
    unSeqResources1.add(unSeqResources.get(5));
    seriesAggregationScanOperator1.initQueryDataSource(
        new QueryDataSource(seqResources1, unSeqResources1));

    SeriesAggregationScanOperator seriesAggregationScanOperator2 =
        new SeriesAggregationScanOperator(
            planNodeId2,
            measurementPath1,
            Ordering.ASC,
            scanOptionsBuilder.build(),
            driverContext.getOperatorContexts().get(0),
            aggregators,
            initTimeRangeIterator(groupByTimeParameter, true, true, ZoneId.systemDefault()),
            groupByTimeParameter,
            DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES,
            true);

    List<TsFileResource> seqResources2 = new ArrayList<>();
    List<TsFileResource> unSeqResources2 = new ArrayList<>();
    seqResources2.add(seqResources.get(2));
    seqResources2.add(seqResources.get(4));
    unSeqResources2.add(unSeqResources.get(2));
    unSeqResources2.add(unSeqResources.get(4));
    seriesAggregationScanOperator2.initQueryDataSource(
        new QueryDataSource(seqResources2, unSeqResources2));

    List<Operator> children = new ArrayList<>();
    children.add(seriesAggregationScanOperator1);
    children.add(seriesAggregationScanOperator2);

    List<TreeAggregator> finalAggregators = new ArrayList<>();
    List<Accumulator> accumulators =
        AccumulatorFactory.createBuiltinAccumulators(
            aggregationTypes,
            TSDataType.INT32,
            Collections.emptyList(),
            Collections.emptyMap(),
            true);
    for (int i = 0; i < accumulators.size(); i++) {
      finalAggregators.add(
          new TreeAggregator(accumulators.get(i), AggregationStep.FINAL, inputLocations.get(i)));
    }

    return new AggregationOperator(
        driverContext.getOperatorContexts().get(2),
        finalAggregators,
        initTimeRangeIterator(groupByTimeParameter, true, true, ZoneId.systemDefault()),
        children,
        false,
        DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES);
  }
@param aggregationTypes Aggregation function used in test
@param groupByTimeParameter group by time parameter
@param inputLocations each inputLocation is used in one aggregator
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/AggregationOperatorTest.java