You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2022/10/31 02:39:06 UTC

[iotdb] branch lmh/planOpt created (now a43c323e06)

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

hui pushed a change to branch lmh/planOpt
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at a43c323e06 fix

This branch includes the following new commits:

     new 5590a67254 add test
     new a43c323e06 fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 02/02: fix

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/planOpt
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit a43c323e0671ccc7df3a3d2479abd50c959cec1f
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Mon Oct 31 10:38:44 2022 +0800

    fix
---
 .../apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
index 74b2b9b5c5..493b6814ca 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
@@ -287,21 +287,24 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
     Filter globalTimeFilter = null;
     boolean hasValueFilter = false;
     if (queryStatement.getWhereCondition() != null) {
-      Expression predicate = queryStatement.getWhereCondition().getPredicate();
       WhereCondition whereCondition = queryStatement.getWhereCondition();
+      Expression predicate = whereCondition.getPredicate();
+
       Pair<Filter, Boolean> resultPair =
           ExpressionAnalyzer.extractGlobalTimeFilter(predicate, true, true);
+      globalTimeFilter = resultPair.left;
+      hasValueFilter = resultPair.right;
+
       predicate = ExpressionAnalyzer.evaluatePredicate(predicate);
 
-      // set where condition to null if predicate is true
-      if (predicate.getExpressionType().equals(ExpressionType.CONSTANT)
-          && Boolean.parseBoolean(predicate.getExpressionString())) {
+      // set where condition to null if predicate is true or time filter.
+      if (!hasValueFilter
+          || (predicate.getExpressionType().equals(ExpressionType.CONSTANT)
+              && Boolean.parseBoolean(predicate.getExpressionString()))) {
         queryStatement.setWhereCondition(null);
       } else {
         whereCondition.setPredicate(predicate);
       }
-      globalTimeFilter = resultPair.left;
-      hasValueFilter = resultPair.right;
     }
     if (queryStatement.isGroupByTime()) {
       GroupByTimeComponent groupByTimeComponent = queryStatement.getGroupByTimeComponent();


[iotdb] 01/02: add test

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/planOpt
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 5590a67254cf27036dc6ed1106826095e46fa8ac
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Mon Oct 31 10:15:26 2022 +0800

    add test
---
 .../apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java
index b1eed72479..43c2420f3c 100644
--- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java
+++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java
@@ -153,7 +153,7 @@ public class QueryLogicalPlanUtil {
 
   /* Simple Query */
   static {
-    String sql = "SELECT ** FROM root.sg.d2 LIMIT 10 OFFSET 10";
+    String sql = "SELECT ** FROM root.sg.d2 WHERE time > 100 LIMIT 10 OFFSET 10";
 
     QueryId queryId = new QueryId("test");
     List<PlanNode> sourceNodeList = new ArrayList<>();
@@ -175,6 +175,15 @@ public class QueryLogicalPlanUtil {
     sourceNodeList.add(
         new AlignedSeriesScanNode(
             queryId.genPlanNodeId(), (AlignedPath) schemaMap.get("root.sg.d2.a"), Ordering.ASC));
+
+    for (PlanNode sourceNode : sourceNodeList) {
+      if (sourceNode instanceof SeriesScanNode) {
+        ((SeriesScanNode) sourceNode).setTimeFilter(TimeFilter.gt(100));
+      } else if (sourceNode instanceof AlignedSeriesScanNode) {
+        ((AlignedSeriesScanNode) sourceNode).setTimeFilter(TimeFilter.gt(100));
+      }
+    }
+
     TimeJoinNode timeJoinNode =
         new TimeJoinNode(queryId.genPlanNodeId(), Ordering.ASC, sourceNodeList);
     OffsetNode offsetNode = new OffsetNode(queryId.genPlanNodeId(), timeJoinNode, 10);