@Test
  public void mergeAggrOnOneSeriesTest() {
    double[][] retArray = {
      {1.4508E7, 7250.374812593702, 7250.374812593702, 1.4508E7},
      {626750.0, 1250.9980039920158, 1250.9980039920158, 626750.0},
      {1.4508E7, 2001, 7250.374812593702, 7250.374812593702},
      {1.4508E7, 2001, 7250.374812593702, 7250.374812593702, 2001, 1.4508E7}
    };

    try (Connection connection = EnvFactory.getEnv().getConnection();
        Statement statement = connection.createStatement()) {

      int cnt = 0;
      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT sum(s0), avg(s2), avg(s0), sum(s2)"
                  + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000")) {
        while (resultSet.next()) {
          double[] ans = new double[4];
          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s0)));
          ans[3] = Double.parseDouble(resultSet.getString(sum(d0s2)));
          assertArrayEquals(retArray[cnt], ans, DETLA);
          cnt++;
        }
        Assert.assertEquals(1, cnt);
      }

      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT sum(s0), avg(s2), avg(s0), sum(s2)"
                  + "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 2000")) {
        while (resultSet.next()) {
          double[] ans = new double[4];
          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s0)));
          ans[3] = Double.parseDouble(resultSet.getString(sum(d0s2)));
          assertArrayEquals(retArray[cnt], ans, DETLA);
          cnt++;
        }
        Assert.assertEquals(2, cnt);
      }

      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT sum(s0), count(s0), avg(s2), avg(s0)"
                  + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000")) {
        while (resultSet.next()) {
          double[] ans = new double[4];
          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
          ans[1] = Double.parseDouble(resultSet.getString(count(d0s0)));
          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s0)));
          assertArrayEquals(retArray[cnt], ans, DETLA);
          cnt++;
        }
        Assert.assertEquals(3, cnt);
      }

      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT sum(s2), count(s0), avg(s2), avg(s1), count(s2),sum(s0)"
                  + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000")) {
        while (resultSet.next()) {
          double[] ans = new double[6];
          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s2)));
          ans[1] = Double.parseDouble(resultSet.getString(count(d0s0)));
          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s1)));
          ans[4] = Double.parseDouble(resultSet.getString(count(d0s2)));
          ans[5] = Double.parseDouble(resultSet.getString(sum(d0s0)));
          assertArrayEquals(retArray[cnt], ans, DETLA);
          cnt++;
        }
        Assert.assertEquals(4, cnt);
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
test aggregation query with more than one functions on one series
integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java