@Test
  public void getDeduplicatedDescriptorsTest1() {
    PartialPath seriesPath1 = new PartialPath(new String[] {"root", "sg", "d1", "s1"});
    List<TAggregationType> aggregationTypeList = new ArrayList<>();
    aggregationTypeList.add(TAggregationType.COUNT);
    aggregationTypeList.add(TAggregationType.AVG);
    aggregationTypeList.add(TAggregationType.SUM);
    List<AggregationDescriptor> descriptorList = new ArrayList<>();
    for (TAggregationType aggregationType : aggregationTypeList) {
      descriptorList.add(
          new AggregationDescriptor(
              aggregationType.name().toLowerCase(),
              AggregationStep.PARTIAL,
              Collections.singletonList(new TimeSeriesOperand(seriesPath1))));
    }
    List<AggregationDescriptor> deduplicatedDescriptors =
        AggregationNode.getDeduplicatedDescriptors(descriptorList);
    assertEquals(1, deduplicatedDescriptors.size());
    assertEquals(TAggregationType.AVG, deduplicatedDescriptors.get(0).getAggregationType());

    aggregationTypeList = new ArrayList<>();
    aggregationTypeList.add(TAggregationType.COUNT);
    aggregationTypeList.add(TAggregationType.SUM);
    aggregationTypeList.add(TAggregationType.AVG);
    descriptorList = new ArrayList<>();
    for (TAggregationType aggregationType : aggregationTypeList) {
      descriptorList.add(
          new AggregationDescriptor(
              aggregationType.name().toLowerCase(),
              AggregationStep.PARTIAL,
              Collections.singletonList(new TimeSeriesOperand(seriesPath1))));
    }
    deduplicatedDescriptors = AggregationNode.getDeduplicatedDescriptors(descriptorList);
    assertEquals(1, deduplicatedDescriptors.size());
    assertEquals(TAggregationType.AVG, deduplicatedDescriptors.get(0).getAggregationType());

    aggregationTypeList = new ArrayList<>();
    aggregationTypeList.add(TAggregationType.AVG);
    aggregationTypeList.add(TAggregationType.COUNT);
    aggregationTypeList.add(TAggregationType.SUM);
    descriptorList = new ArrayList<>();
    for (TAggregationType aggregationType : aggregationTypeList) {
      descriptorList.add(
          new AggregationDescriptor(
              aggregationType.name().toLowerCase(),
              AggregationStep.PARTIAL,
              Collections.singletonList(new TimeSeriesOperand(seriesPath1))));
    }
    deduplicatedDescriptors = AggregationNode.getDeduplicatedDescriptors(descriptorList);
    assertEquals(1, deduplicatedDescriptors.size());
    assertEquals(TAggregationType.AVG, deduplicatedDescriptors.get(0).getAggregationType());

    // try output final
    descriptorList = new ArrayList<>();
    for (TAggregationType aggregationType : aggregationTypeList) {
      descriptorList.add(
          new AggregationDescriptor(
              aggregationType.name().toLowerCase(),
              AggregationStep.SINGLE,
              Collections.singletonList(new TimeSeriesOperand(seriesPath1))));
    }
    deduplicatedDescriptors = AggregationNode.getDeduplicatedDescriptors(descriptorList);
    assertEquals(3, deduplicatedDescriptors.size());
    assertEquals(TAggregationType.AVG, deduplicatedDescriptors.get(0).getAggregationType());
    assertEquals(TAggregationType.COUNT, deduplicatedDescriptors.get(1).getAggregationType());
    assertEquals(TAggregationType.SUM, deduplicatedDescriptors.get(2).getAggregationType());
  }
Test AVG with COUNT and SUM (former or later).
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/process/AggregationNodeSerdeTest.java