You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/11/01 20:59:47 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7633: Enhance MergeRangeFilterOptimizer to rewrite predicate A < 10 OR A = …

Jackie-Jiang commented on a change in pull request #7633:
URL: https://github.com/apache/pinot/pull/7633#discussion_r740523151



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/optimizer/filter/MergeRangeFilterOptimizer.java
##########
@@ -187,8 +189,88 @@ public Expression optimize(Expression filterExpression, @Nullable Schema schema)
         return filterExpression;
       }
     } else if (operator.equals(FilterKind.OR.name())) {
-      function.getOperands().replaceAll(c -> optimize(c, schema));
-      return filterExpression;
+      List<Expression> children = function.getOperands();
+      Map<String, Set<Range>> rangeMap = new HashMap<>();

Review comment:
       `Range` does not have `equals()` or `hashCode()` implemented, so should not be used in a `Set`

##########
File path: pinot-core/src/test/java/org/apache/pinot/core/query/optimizer/QueryOptimizerTest.java
##########
@@ -67,8 +67,8 @@ public void testNoFilter() {
   @Test
   public void testFlattenAndOrFilter() {
     String query =
-        "SELECT * FROM testTable WHERE ((int = 4 OR (long = 5 AND (float = 9 AND double = 7.5))) OR string = 'foo') "
-            + "OR bytes = 'abc'";
+        "SELECT * FROM testTable WHERE ((int = 4 OR "
+            + "(long = 5 AND (float = 9 AND double = 7.5))) OR string = 'foo') OR bytes = '20'";

Review comment:
       Why changing the `bytes` predicate?

##########
File path: pinot-core/src/test/java/org/apache/pinot/core/query/optimizer/QueryOptimizerTest.java
##########
@@ -318,6 +318,14 @@ public void testQueries() {
         "SELECT * FROM testTable WHERE int > 20 OR int < 30");
     testQuery("SELECT * FROM testTable WHERE int > 10 AND int > 20 OR long < 30 AND long < 40",
         "SELECT * FROM testTable WHERE int > 20 OR long < 30");
+    testSQLQuery("SELECT * FROM testTable WHERE int > 10 OR int = 10",
+        "SELECT * FROM testTable WHERE int >= 10");
+    testSQLQuery("SELECT * FROM testTable WHERE int = 10 OR int > 10",
+        "SELECT * FROM testTable WHERE int >= 10");
+    testSQLQuery("SELECT * FROM testTable WHERE int = 10 OR int > 10 OR int > 20 OR int < 50",
+        "SELECT * FROM testTable WHERE int >= 10 OR int > 20 OR int < 50");

Review comment:
       Ideally this should be optimized to match all




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org