You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2026/08/31 13:35:36 UTC

(iotdb) branch master updated: Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest (#18556)

This is an automated email from the ASF dual-hosted git repository.

JackieTien97 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new e096f6316e6 Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest (#18556)
e096f6316e6 is described below

commit e096f6316e61777167de4e6b133b8ac397e81dcd
Author: Jackie Tien <ja...@gmail.com>
AuthorDate: Mon Aug 31 21:35:29 2026 +0800

    Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest (#18556)
---
 .../it/query/recent/IoTDBTableAggregationIT.java     | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
index 44d2278a866..518b3da1fdd 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
@@ -36,6 +36,10 @@ import org.junit.runner.RunWith;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
 import static org.apache.iotdb.db.it.utils.TestUtils.tableAssertTestFail;
@@ -5901,6 +5905,13 @@ public class IoTDBTableAggregationIT {
       try (ResultSet resultSet = statement.executeQuery("EXPLAIN (FORMAT JSON) " + query)) {
         Assert.assertTrue(resultSet.next());
         String plan = resultSet.getString(1);
+        // The PARTIAL/FINAL split only exists when the scanned data spans multiple DataRegions.
+        // Under randomized partition allocation (e.g. the SHUFFLE strategy used by
+        // IoTDBTableAggregation2IT), all devices may occasionally land in one single region,
+        // where a SINGLE-step aggregation is the correct plan, so the check must be skipped.
+        if (countDistinctRegionIds(plan) < 2) {
+          return;
+        }
         Assert.assertTrue(
             "Expected a PARTIAL aggregation in plan: " + plan, plan.contains("PARTIAL"));
         Assert.assertTrue("Expected a FINAL aggregation in plan: " + plan, plan.contains("FINAL"));
@@ -5910,6 +5921,15 @@ public class IoTDBTableAggregationIT {
     }
   }
 
+  private static int countDistinctRegionIds(String plan) {
+    Set<String> regionIds = new HashSet<>();
+    Matcher matcher = Pattern.compile("\"RegionId\"\\s*:\\s*\"(\\d+)\"").matcher(plan);
+    while (matcher.find()) {
+      regionIds.add(matcher.group(1));
+    }
+    return regionIds.size();
+  }
+
   @Test
   public void rateFunctionsBoundaryTest() {
     tableResultSetEqualTest(