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

jackietien 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 f94865ee1ca Fix the aggregation push down when inner-query was 
optimized to AggTableScan
f94865ee1ca is described below

commit f94865ee1cafe1938f574c0c5a22e534d2b9c125
Author: Weihao Li <[email protected]>
AuthorDate: Fri Oct 25 09:29:42 2024 +0800

    Fix the aggregation push down when inner-query was optimized to AggTableScan
---
 .../it/db/it/IoTDBMultiIDsWithAttributesTableIT.java          | 11 +++++++++++
 .../planner/optimizations/PushAggregationIntoTableScan.java   |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java
index ec659eddb42..fa1a07f305e 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java
@@ -616,6 +616,17 @@ public class IoTDBMultiIDsWithAttributesTableIT {
         DATABASE_NAME);
 
     // TODO select count(*),count(t1) from (select avg(num+1) as t1 from 
table0) where time < 0
+
+    expectedHeader = buildHeaders(1);
+    retArray =
+        new String[] {
+          "10,",
+        };
+    tableResultSetEqualTest(
+        "select count(*) from (select device from table0 group by device, 
level)",
+        expectedHeader,
+        retArray,
+        DATABASE_NAME);
   }
 
   @Test
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushAggregationIntoTableScan.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushAggregationIntoTableScan.java
index 07b519220d5..d5d4defd8c6 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushAggregationIntoTableScan.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushAggregationIntoTableScan.java
@@ -96,7 +96,10 @@ public class PushAggregationIntoTableScan implements 
PlanOptimizer {
           tableScanNode = (TableScanNode) projectNode.getChild();
         }
       }
-      if (tableScanNode == null) { // no need to optimize
+
+      // only optimize AggregationNode with raw TableScanNode
+      if (tableScanNode == null
+          || tableScanNode instanceof AggregationTableScanNode) { // no need 
to optimize
         return node;
       }
 

Reply via email to