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

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


The following commit(s) were added to refs/heads/EnhancedDeviceCrossRegionIT by 
this push:
     new 8f6c554f647 Fix some found bugs
8f6c554f647 is described below

commit 8f6c554f6471dd0f8f32a00dd8aa534033214897
Author: JackieTien97 <[email protected]>
AuthorDate: Tue Sep 2 15:23:31 2025 +0800

    Fix some found bugs
---
 .../it/db/it/IoTDBPatternAggregationIT.java        |  8 ++++++
 .../it/db/it/IoTDBPatternRecognitionIT.java        | 11 ++++++++
 .../relational/it/db/it/IoTDBWindowFunctionIT.java |  8 +++---
 .../relational/it/db/it/IoTDBWindowTVFIT.java      | 32 +++++++++++-----------
 .../iotdb/confignode/conf/ConfigNodeConfig.java    |  2 +-
 .../distribute/TableDistributedPlanGenerator.java  | 19 ++++++-------
 .../planner/optimizations/SortElimination.java     | 13 ++-------
 .../apache/iotdb/commons/conf/CommonConfig.java    |  2 +-
 8 files changed, 52 insertions(+), 43 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternAggregationIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternAggregationIT.java
index 6e543f64cff..617eecc2256 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternAggregationIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternAggregationIT.java
@@ -145,6 +145,7 @@ public class IoTDBPatternAggregationIT {
             + ")"
             + "MATCH_RECOGNIZE ( "
             + "    PARTITION BY device_id "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RPR_FIRST(A.time) AS event_start, "
@@ -193,6 +194,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.count1, m.count2, m.max, m.min, m.sum1, 
m.sum2, m.avg1, m.avg2, m.totalprice "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        COUNT(totalprice) AS count1, "
@@ -246,6 +248,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.label, m.count_0, m.count_1, m.count_2, 
m.count_c, m.final_count_c, m.count_u, m.final_count_u, m.totalprice "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        CLASSIFIER() AS label, "
@@ -298,6 +301,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.label, m.sum, m.sum_c, m.final_sum_c, 
m.sum_u, m.final_sum_u, m.totalprice "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        CLASSIFIER() AS label, "
@@ -348,6 +352,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.label, m.avg, m.avg_c, m.final_avg_c, 
m.avg_u, m.final_avg_u, m.totalprice "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        CLASSIFIER() AS label, "
@@ -390,6 +395,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.firstTime, m.lastTime, m.maxTime, 
m.minTime, m.firstVal, m.lastVal "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "      MATCH_NUMBER() AS match, "
             + "      FIRST_BY(time, totalprice) AS firstTime, "
@@ -439,6 +445,7 @@ public class IoTDBPatternAggregationIT {
             + "ROUND(m.std_0, 6) AS std_0, ROUND(m.std_1, 6) AS std_1, 
ROUND(m.std_2, 6) AS std_2 "
             + "FROM t3 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "      MATCH_NUMBER() AS match, "
             + "      MODE(totalprice) AS mode, "
@@ -475,6 +482,7 @@ public class IoTDBPatternAggregationIT {
         "SELECT m.time, m.match, m.label, m.avg, m.running_avg_b, m.totalprice 
"
             + "FROM t2 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        CLASSIFIER() AS label, "
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternRecognitionIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternRecognitionIT.java
index f645d015a65..070ba0b6348 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternRecognitionIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternRecognitionIT.java
@@ -142,6 +142,7 @@ public class IoTDBPatternRecognitionIT {
             + "FROM beidou "
             + "MATCH_RECOGNIZE ( "
             + "    PARTITION BY device_id "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RPR_FIRST(A.time) AS event_start, "
@@ -184,6 +185,7 @@ public class IoTDBPatternRecognitionIT {
             + ")"
             + "MATCH_RECOGNIZE ( "
             + "    PARTITION BY device_id "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RPR_FIRST(A.time) AS event_start, "
@@ -265,6 +267,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.match, m.price, m.label "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RUNNING RPR_LAST(totalprice) AS price,  "
@@ -348,6 +351,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.price "
             + "FROM t2 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        %s AS price "
             + "    ALL ROWS PER MATCH "
@@ -442,6 +446,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.price "
             + "FROM t2 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        %s AS price "
             + "    ALL ROWS PER MATCH "
@@ -475,6 +480,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.price "
             + "FROM t3 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        %s AS price "
             + "    ONE ROW PER MATCH "
@@ -574,6 +580,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.price "
             + "FROM t2 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        %s AS price "
             + "    ALL ROWS PER MATCH "
@@ -654,6 +661,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.match, m.price, m.lower_or_higher, m.label "
             + "FROM t4 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RUNNING RPR_LAST(totalprice) AS price, "
@@ -691,6 +699,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.match, m.price, m.label, m.prev_label, m.next_label "
             + "FROM t4 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RUNNING RPR_LAST(totalprice) AS price, "
@@ -742,6 +751,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.match, m.price, m.label "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RUNNING RPR_LAST(totalprice) AS price,  "
@@ -883,6 +893,7 @@ public class IoTDBPatternRecognitionIT {
         "SELECT m.time, m.match, m.price, m.label "
             + "FROM t1 "
             + "MATCH_RECOGNIZE ( "
+            + "    ORDER BY time "
             + "    MEASURES "
             + "        MATCH_NUMBER() AS match, "
             + "        RUNNING RPR_LAST(totalprice) AS price,  "
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowFunctionIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowFunctionIT.java
index dc19bcd5d7c..ccc267e1ccd 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowFunctionIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowFunctionIT.java
@@ -130,7 +130,7 @@ public class IoTDBWindowFunctionIT {
           "2021-01-01T09:15:00.000Z,d2,4.0,6,",
         };
     tableResultSetEqualTest(
-        "SELECT *, count(value) OVER () AS cnt FROM demo ORDER BY device",
+        "SELECT *, count(value) OVER () AS cnt FROM demo ORDER BY device,time",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -149,7 +149,7 @@ public class IoTDBWindowFunctionIT {
           "2021-01-01T09:15:00.000Z,d2,4.0,2,",
         };
     tableResultSetEqualTest(
-        "SELECT *, count(value) OVER (PARTITION BY device) AS cnt FROM demo 
ORDER BY device",
+        "SELECT *, count(value) OVER (PARTITION BY device) AS cnt FROM demo 
ORDER BY device, time",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -173,7 +173,7 @@ public class IoTDBWindowFunctionIT {
           "2021-01-01T09:22:00.000Z,null,2.0,2,",
         };
     tableResultSetEqualTest(
-        "SELECT *, count(value) OVER (PARTITION BY device) AS cnt FROM demo2 
ORDER BY device",
+        "SELECT *, count(value) OVER (PARTITION BY device) AS cnt FROM demo2 
ORDER BY device,time",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -278,7 +278,7 @@ public class IoTDBWindowFunctionIT {
           "2021-01-01T09:15:00.000Z,d2,4.0,2,",
         };
     tableResultSetEqualTest(
-        "SELECT *, count(value) OVER (PARTITION BY device ROWS 1 PRECEDING) AS 
cnt FROM demo ORDER BY device",
+        "SELECT *, count(value) OVER (PARTITION BY device ORDER BY time ROWS 1 
PRECEDING) AS cnt FROM demo ORDER BY device",
         expectedHeader,
         retArray,
         DATABASE_NAME);
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
index 24b1c16320c..f5b4a9787f2 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
@@ -269,7 +269,7 @@ public class IoTDBWindowTVFIT {
           "3,2021-01-01T09:05:00.000Z,device1,3,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, long_val FROM 
variation(multi_type, 'long_val', 1.0, false)",
+        "SELECT window_index, time, device_id, long_val FROM 
variation(multi_type ORDER BY time, 'long_val', 1.0, false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -286,7 +286,7 @@ public class IoTDBWindowTVFIT {
           "1,2021-01-01T09:05:00.000Z,device1,3.0,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, float_val FROM 
variation(multi_type, 'float_val', 1.0, true)",
+        "SELECT window_index, time, device_id, float_val FROM 
variation(multi_type ORDER BY time, 'float_val', 1.0, true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -303,7 +303,7 @@ public class IoTDBWindowTVFIT {
           "0,2021-01-01T09:05:00.000Z,device1,3.0,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, double_val FROM 
variation(multi_type, 'double_val', 1.0, true)",
+        "SELECT window_index, time, device_id, double_val FROM 
variation(multi_type ORDER BY time, 'double_val', 1.0, true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -320,7 +320,7 @@ public class IoTDBWindowTVFIT {
           "1,2021-01-01T09:05:00.000Z,device1,false,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, bool_val FROM 
variation(multi_type, 'bool_val', 0.0, true)",
+        "SELECT window_index, time, device_id, bool_val FROM 
variation(multi_type ORDER BY time, 'bool_val', 0.0, true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -337,7 +337,7 @@ public class IoTDBWindowTVFIT {
           "1,2021-01-01T09:05:00.000Z,device1,2,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, str_val FROM 
variation(multi_type, 'str_val', 0.0, true)",
+        "SELECT window_index, time, device_id, str_val FROM 
variation(multi_type ORDER BY time, 'str_val', 0.0, true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -354,7 +354,7 @@ public class IoTDBWindowTVFIT {
           "4,2021-01-01T09:05:00.000Z,device1,0x02,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, blob_val FROM 
variation(multi_type, 'blob_val', 0.0, false)",
+        "SELECT window_index, time, device_id, blob_val FROM 
variation(multi_type ORDER BY time, 'blob_val', 0.0, false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -371,7 +371,7 @@ public class IoTDBWindowTVFIT {
           "3,2021-01-01T09:05:00.000Z,device1,2021-01-01T10:00:00.000Z,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, ts_val FROM 
variation(DATA=>multi_type, COL=>'ts_val', ignore_null=>false)",
+        "SELECT window_index, time, device_id, ts_val FROM 
variation(DATA=>multi_type ORDER BY time, COL=>'ts_val', ignore_null=>false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -388,7 +388,7 @@ public class IoTDBWindowTVFIT {
           "1,2021-01-01T09:05:00.000Z,device1,2021-01-02,"
         };
     tableResultSetEqualTest(
-        "SELECT window_index, time, device_id, date_val FROM 
variation(multi_type, 'date_val', 0.0)",
+        "SELECT window_index, time, device_id, date_val FROM 
variation(multi_type ORDER BY time, 'date_val', 0.0)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -621,7 +621,7 @@ public class IoTDBWindowTVFIT {
           "2,0.6797687270429319,1970-01-01T00:00:00.052Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, 
threshold => 10.0, width => 1000.0, height => 500.0, smooth_On_Pattern => 
false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', 
smooth => 0.5, threshold => 10.0, width => 1000.0, height => 500.0, 
smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -652,7 +652,7 @@ public class IoTDBWindowTVFIT {
           "1,0.6797687270429319,1970-01-01T00:00:00.052Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, 
threshold => 1.0, width => 1000.0, height => 500.0, smooth_On_Pattern => 
false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', 
smooth => 0.5, threshold => 1.0, width => 1000.0, height => 500.0, 
smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -679,7 +679,7 @@ public class IoTDBWindowTVFIT {
           "1,0.6465473220616865,1970-01-01T00:00:00.021Z,1.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, 
threshold => 10.0, width => 10.0, height => 500.0, smooth_On_Pattern => false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', 
smooth => 0.5, threshold => 10.0, width => 10.0, height => 500.0, 
smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -697,7 +697,7 @@ public class IoTDBWindowTVFIT {
           "0,4.637180787192477,1970-01-01T00:00:00.008Z,1.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, 
threshold => 10.0, width => 1000.0, height => 2.0, smooth_On_Pattern => false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1.0,2.0,3.0,2.0,1.0,1.0,1.0,1.0,1.0', 
smooth => 0.5, threshold => 10.0, width => 1000.0, height => 2.0, 
smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -750,7 +750,7 @@ public class IoTDBWindowTVFIT {
           "3,0.6797687270429319,1970-01-01T00:00:00.052Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,{2.0,3.0,2.0}+,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, 
threshold => 100.0, width => 1000.0, height => 500.0, smooth_On_Pattern => 
false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => 
'1.0,{2.0,3.0,2.0}+,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, threshold => 100.0, 
width => 1000.0, height => 500.0, smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -797,7 +797,7 @@ public class IoTDBWindowTVFIT {
           "3,0.0,1970-01-01T00:00:00.052Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,1.0,{1.0,2.0,3.0,2.0}*,1.0,1.0,1.0,1.0,1.0', smooth 
=> 0.5, threshold => 100.0, width => 1000.0, height => 500.0, smooth_On_Pattern 
=> false)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => 
'1.0,1.0,{1.0,2.0,3.0,2.0}*,1.0,1.0,1.0,1.0,1.0', smooth => 0.5, threshold => 
100.0, width => 1000.0, height => 500.0, smooth_On_Pattern => false)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -827,7 +827,7 @@ public class IoTDBWindowTVFIT {
           "3,1.7704361692956723,1970-01-01T00:00:00.046Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1,2.0,1.0', smooth => 0.5, threshold => 100.0, width => 
1000.0, height => 500.0, smooth_On_Pattern => true)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1,2.0,1.0', smooth => 0.5, threshold 
=> 100.0, width => 1000.0, height => 500.0, smooth_On_Pattern => true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
@@ -855,7 +855,7 @@ public class IoTDBWindowTVFIT {
           "2,0.09999999999999994,1970-01-01T00:00:00.052Z,2.0,0,",
         };
     tableResultSetEqualByDataTypeTest(
-        "select * from pattern_match(data => t1, time_col => 'time', data_col 
=> 'value', pattern => '1.0,1.2,1.0', smooth => 0.5, threshold => 1.0, width => 
1000.0, height => 500.0, smooth_On_Pattern => true)",
+        "select * from pattern_match(data => t1 ORDER BY time, time_col => 
'time', data_col => 'value', pattern => '1.0,1.2,1.0', smooth => 0.5, threshold 
=> 1.0, width => 1000.0, height => 500.0, smooth_On_Pattern => true)",
         expectedHeader,
         retArray,
         DATABASE_NAME);
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
index 57e619a9baa..12e1224d58d 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
@@ -82,7 +82,7 @@ public class ConfigNodeConfig {
   private String seriesPartitionExecutorClass =
       "org.apache.iotdb.commons.partition.executor.hash.BKDRHashExecutor";
 
-  private String dataPartitionAllocationStrategy = "INHERIT";
+  private String dataPartitionAllocationStrategy = "SHUFFLE";
 
   /** The policy of extension SchemaRegionGroup for each Database. */
   private RegionGroupExtensionPolicy schemaRegionGroupExtensionPolicy =
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java
index 442f40c86a9..5d52e6c05ec 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java
@@ -634,15 +634,6 @@ public class TableDistributedPlanGenerator
   @Override
   public List<PlanNode> visitPatternRecognition(PatternRecognitionNode node, 
PlanContext context) {
     context.clearExpectedOrderingScheme();
-    if (node.getPartitionBy().isEmpty()) {
-      Optional<OrderingScheme> orderingScheme = node.getOrderingScheme();
-      orderingScheme.ifPresent(scheme -> 
nodeOrderingMap.put(node.getPlanNodeId(), scheme));
-    }
-
-    if (node.getChildren().isEmpty()) {
-      return Collections.singletonList(node);
-    }
-
     boolean canSplitPushDown = (node.getChild() instanceof GroupNode);
     List<PlanNode> childrenNodes = node.getChild().accept(this, context);
     if (childrenNodes.size() == 1) {
@@ -760,7 +751,15 @@ public class TableDistributedPlanGenerator
           new MergeSortNode(
               queryId.genPlanNodeId(), context.expectedOrderingScheme, 
node.getOutputSymbols());
       for (PlanNode node1 : constructDeviceTableScanByRegionReplicaSet(node, 
context)) {
-        mergeSortNode.addChild(node1);
+        if (canSortEliminated(
+            mergeSortNode.getOrderingScheme(), 
nodeOrderingMap.get(node1.getPlanNodeId()))) {
+          mergeSortNode.addChild(node1);
+        } else {
+          SortNode subSortNode =
+              new SortNode(
+                  queryId.genPlanNodeId(), node1, 
mergeSortNode.getOrderingScheme(), false, false);
+          mergeSortNode.addChild(subSortNode);
+        }
       }
       nodeOrderingMap.put(mergeSortNode.getPlanNodeId(), 
mergeSortNode.getOrderingScheme());
       result.add(mergeSortNode);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/SortElimination.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/SortElimination.java
index e581678a58f..bb276f07150 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/SortElimination.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/SortElimination.java
@@ -126,12 +126,7 @@ public class SortElimination implements PlanOptimizer {
       for (PlanNode child : node.getChildren()) {
         newNode.addChild(child.accept(this, context));
       }
-
-      // We can continue to eliminate sort when there is only PARTITION BY
-      if (node.getSpecification().getPartitionBy().isEmpty()
-          || node.getSpecification().getOrderingScheme().isPresent()) {
-        context.setCannotEliminateSort(true);
-      }
+      context.setCannotEliminateSort(true);
       return newNode;
     }
 
@@ -141,11 +136,7 @@ public class SortElimination implements PlanOptimizer {
       for (PlanNode child : node.getChildren()) {
         newNode.addChild(child.accept(this, context));
       }
-
-      // Same as window function
-      if (node.getPartitionBy().isEmpty() || 
node.getOrderingScheme().isPresent()) {
-        context.setCannotEliminateSort(true);
-      }
+      context.setCannotEliminateSort(true);
       return newNode;
     }
   }
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
index c5d0ecc558f..bb85c74940e 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
@@ -179,7 +179,7 @@ public class CommonConfig {
   private long timePartitionOrigin = 0;
 
   /** Time partition interval in milliseconds. */
-  private long timePartitionInterval = 604_800_000;
+  private long timePartitionInterval = 60_000;
 
   /** This variable set timestamp precision as millisecond, microsecond or 
nanosecond. */
   private String timestampPrecision = "ms";

Reply via email to