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

caogaofei pushed a commit to branch ty/TableModelGrammar
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/ty/TableModelGrammar by this 
push:
     new 78c14b4e2f2 fix or using or expression predicate terms list bug in 
IndexScan
78c14b4e2f2 is described below

commit 78c14b4e2f29066ddf2ed1dff0895341df084f99
Author: Beyyes <[email protected]>
AuthorDate: Sun May 19 22:14:31 2024 +0800

    fix or using or expression predicate terms list bug in IndexScan
---
 .../planner/optimizations/IndexScan.java           | 41 +++++++++++-----------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/IndexScan.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/IndexScan.java
index 70945da8185..67b11eb95fd 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/IndexScan.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/IndexScan.java
@@ -157,31 +157,32 @@ public class IndexScan implements RelationalPlanOptimizer 
{
 
   private static List<Expression> getConjunctionExpressions(
       Expression predicate, TableScanNode node) {
-    if (predicate != null) {
+    if (predicate == null) {
+      return Collections.emptyList();
+    }
+
+    Set<String> idOrAttributeColumnNames =
+        node.getIdAndAttributeIndexMap().keySet().stream()
+            .map(Symbol::getName)
+            .collect(Collectors.toSet());
+    if (predicate instanceof LogicalExpression
+        && ((LogicalExpression) predicate).getOperator() == 
LogicalExpression.Operator.AND) {
       List<Expression> resultExpressions = new ArrayList<>();
-      Set<String> idOrAttributeColumnNames =
-          node.getIdAndAttributeIndexMap().keySet().stream()
-              .map(Symbol::getName)
-              .collect(Collectors.toSet());
-      if (predicate instanceof LogicalExpression) {
-        for (Expression subExpression : ((LogicalExpression) 
predicate).getTerms()) {
-          if (Boolean.TRUE.equals(
-              new PredicatePushIntoIndexScanChecker(idOrAttributeColumnNames)
-                  .process(subExpression))) {
-            resultExpressions.add(subExpression);
-          }
-        }
-      } else {
-        if (Boolean.FALSE.equals(
-            new 
PredicatePushIntoIndexScanChecker(idOrAttributeColumnNames).process(predicate)))
 {
-          resultExpressions = Collections.emptyList();
-        } else {
-          resultExpressions = Collections.singletonList(predicate);
+      for (Expression subExpression : ((LogicalExpression) 
predicate).getTerms()) {
+        if (Boolean.TRUE.equals(
+            new PredicatePushIntoIndexScanChecker(idOrAttributeColumnNames)
+                .process(subExpression))) {
+          resultExpressions.add(subExpression);
         }
       }
       return resultExpressions;
-    } else {
+    }
+
+    if (Boolean.FALSE.equals(
+        new 
PredicatePushIntoIndexScanChecker(idOrAttributeColumnNames).process(predicate)))
 {
       return Collections.emptyList();
+    } else {
+      return Collections.singletonList(predicate);
     }
   }
 

Reply via email to