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 2024/10/15 12:18:02 UTC
(iotdb) branch master updated: Push down completely when group-by Aggregation with only one device entry
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 9c8c1ed5306 Push down completely when group-by Aggregation with only one device entry
9c8c1ed5306 is described below
commit 9c8c1ed5306ddf436781666220753bca5affe7c4
Author: Weihao Li <60...@users.noreply.github.com>
AuthorDate: Tue Oct 15 20:17:56 2024 +0800
Push down completely when group-by Aggregation with only one device entry
---
.../PushAggregationIntoTableScan.java | 13 ++++++----
.../plan/relational/analyzer/AggregationTest.java | 29 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 5 deletions(-)
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 771135627c9..df3a51706f8 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
@@ -160,13 +160,15 @@ public class PushAggregationIntoTableScan implements PlanOptimizer {
}
// calculate DataSet part
+ boolean singleDeviceEntry = tableScanNode.getDeviceEntries().size() < 2;
if (groupingKeys.isEmpty()) {
// GlobalAggregation
- if (tableScanNode.getDeviceEntries().size() < 2) {
+ if (singleDeviceEntry) {
return PushDownLevel.COMPLETE;
+ } else {
+ // We need to two-stage Aggregation to combine Aggregation result of different DeviceEntry
+ return PushDownLevel.PARTIAL;
}
- // We need to two-stage Aggregation to combine Aggregation result of different DeviceEntry
- return PushDownLevel.PARTIAL;
}
List<FunctionCall> dateBinFunctionsOfTime = new ArrayList<>();
@@ -185,8 +187,9 @@ public class PushAggregationIntoTableScan implements PlanOptimizer {
// appear in groupingKeys.
return PushDownLevel.NOOP;
- } else if (ImmutableSet.copyOf(groupingKeys)
- .containsAll(tableScanNode.getIdColumnsInTableStore(metadata, session))) {
+ } else if (singleDeviceEntry
+ || ImmutableSet.copyOf(groupingKeys)
+ .containsAll(tableScanNode.getIdColumnsInTableStore(metadata, session))) {
// If all ID columns appear in groupingKeys and no Measurement column appears, we can push
// down completely.
return PushDownLevel.COMPLETE;
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AggregationTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AggregationTest.java
index 59ca723b02c..91d72d587b8 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AggregationTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AggregationTest.java
@@ -622,6 +622,35 @@ public class AggregationTest {
"testdb.table1",
ImmutableList.of("tag1", "tag2", "tag3", "attr1", "time", "count"),
ImmutableSet.of("tag1", "tag2", "tag3", "attr1", "time", "s2")))));
+
+ // Global Aggregation or partialPushDown Aggregation with only one deviceEntry
+
+ // Output - AggTableScan
+ assertPlan(
+ planTester.createPlan("SELECT count(s2) FROM table1 where tag1='beijing' and tag2='A1'"),
+ output(
+ aggregationTableScan(
+ singleGroupingSet(),
+ ImmutableList.of(), // UnStreamable
+ Optional.empty(),
+ SINGLE,
+ "testdb.table1",
+ ImmutableList.of("count"),
+ ImmutableSet.of("s2"))));
+
+ assertPlan(
+ planTester.createPlan(
+ "SELECT count(s2) FROM table1 where tag1='beijing' and tag2='A1' group by tag3"),
+ output(
+ project(
+ aggregationTableScan(
+ singleGroupingSet("tag3"),
+ ImmutableList.of("tag3"),
+ Optional.empty(),
+ SINGLE,
+ "testdb.table1",
+ ImmutableList.of("tag3", "count"),
+ ImmutableSet.of("s2", "tag3")))));
}
@Test