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 316c93bd315 Fix row-order assumptions in time duration tag aggregation
IT (#18926)
316c93bd315 is described below
commit 316c93bd3157cd67c53c8fa69392bcb0ee505cef
Author: Caideyipi <[email protected]>
AuthorDate: Fri Oct 23 14:57:35 2026 +0800
Fix row-order assumptions in time duration tag aggregation IT (#18926)
---
.../db/it/aggregation/IoTDBTimeDurationIT.java | 39 +++++++++++++++++++---
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBTimeDurationIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBTimeDurationIT.java
index 75743994b20..c6d8079abb4 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBTimeDurationIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBTimeDurationIT.java
@@ -20,6 +20,7 @@
package org.apache.iotdb.db.it.aggregation;
import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
@@ -31,9 +32,20 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
import static org.apache.iotdb.db.it.utils.TestUtils.assertTestFail;
import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
@@ -213,7 +225,7 @@ public class IoTDBTimeDurationIT {
}
@Test
- public void testTimeDurationManyColumnOnManyDataRegion() {
+ public void testTimeDurationManyColumnOnManyDataRegion() throws SQLException
{
// normal
String[] expectedHeader =
new String[] {
@@ -345,10 +357,27 @@ public class IoTDBTimeDurationIT {
// group by tags
expectedHeader = new String[] {"city", "time_duration(s1)"};
retArray = new String[] {"Beijing,1677570933,", "Nanjing,1677570938,"};
- resultSetEqualTest(
- "select time_duration(s1) from root.db1.**,root.db.** group by
tags(city)",
- expectedHeader,
- retArray);
+ // GROUP BY TAGS does not guarantee row order, so check each DataNode
independently.
+ for (DataNodeWrapper dataNode :
EnvFactory.getEnv().getDataNodeWrapperList()) {
+ try (Connection connection = EnvFactory.getEnv().getConnection(dataNode);
+ Statement statement = connection.createStatement();
+ ResultSet resultSet =
+ statement.executeQuery(
+ "select time_duration(s1) from root.db1.**,root.db.** group
by tags(city)")) {
+ ResultSetMetaData metaData = resultSet.getMetaData();
+ assertEquals(expectedHeader.length, metaData.getColumnCount());
+ for (int i = 0; i < expectedHeader.length; i++) {
+ assertEquals(expectedHeader[i], metaData.getColumnName(i + 1));
+ }
+ Set<String> remainingRows = new HashSet<>(Arrays.asList(retArray));
+ while (resultSet.next()) {
+ String row =
+ resultSet.getString("city") + "," +
resultSet.getString("time_duration(s1)") + ",";
+ assertTrue(dataNode.getIpAndPortString() + ": " + row,
remainingRows.remove(row));
+ }
+ assertTrue(dataNode.getIpAndPortString() + ": " + remainingRows,
remainingRows.isEmpty());
+ }
+ }
// group by time
expectedHeader =