You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/08/27 16:06:29 UTC

[GitHub] [calcite] alimans3 opened a new pull request, #2887: FilterJoinRule cannot simplify left join to inner join for `WHERE RHS…

alimans3 opened a new pull request, #2887:
URL: https://github.com/apache/calcite/pull/2887

   ….C1 IS NOT NULL OR RHS.C2 IS NOT NULL`


-- 
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@calcite.apache.org

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


[GitHub] [calcite] libenchao commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
libenchao commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r957362319


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -149,14 +149,45 @@ public static boolean allStrong(List<RexNode> operands) {
     return operands.stream().allMatch(Strong::isStrong);
   }
 
-  /** Returns whether an expression is definitely not true. */
+  /** Returns whether an expression is definitely not true by either it being analyzed to be not

Review Comment:
   It's not necessary to change the comment for `isNotTrue`



##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -149,14 +149,45 @@ public static boolean allStrong(List<RexNode> operands) {
     return operands.stream().allMatch(Strong::isStrong);
   }
 
-  /** Returns whether an expression is definitely not true. */
+  /** Returns whether an expression is definitely not true by either it being analyzed to be not
+   * true or null. */
   public boolean isNotTrue(RexNode node) {
+    return isPredicateNotTrue(node) || isNull(node);
+  }
+
+  /** Returns whether an expression is definitely not true. */
+  public boolean isPredicateNotTrue(RexNode node) {

Review Comment:
   Why do you add this public method? Can it be merged into `isNotTrue`?



-- 
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@calcite.apache.org

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


[GitHub] [calcite] libenchao commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
libenchao commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r956668971


##########
core/src/main/java/org/apache/calcite/plan/StrongPredicateAnalyzer.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexNode;
+
+import java.util.List;
+
+/**
+ * Utilities for checking if a predicate is definitely false based on a strong policy.
+ */
+public final class StrongPredicateAnalyzer {

Review Comment:
   Do you really need to add a new util class? How about just adding these methods to `Strong` since we already have many similar methods.
   Besides, adding methods to `Strong` makes Calcite more extensible, e.g., some downstream projects could extends `Strong` and override some methods to add their own logics.



-- 
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@calcite.apache.org

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


[GitHub] [calcite] libenchao closed pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
libenchao closed pull request #2887: [CALCITE-5247]  FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`
URL: https://github.com/apache/calcite/pull/2887


-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r957408247


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -149,14 +149,45 @@ public static boolean allStrong(List<RexNode> operands) {
     return operands.stream().allMatch(Strong::isStrong);
   }
 
-  /** Returns whether an expression is definitely not true. */
+  /** Returns whether an expression is definitely not true by either it being analyzed to be not

Review Comment:
   done



-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r958796188


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -151,12 +151,41 @@ public static boolean allStrong(List<RexNode> operands) {
 
   /** Returns whether an expression is definitely not true. */
   public boolean isNotTrue(RexNode node) {
+    return isPredicateNotTrue(node) || isNull(node);

Review Comment:
   it is doable, it covers more cases this way hence the new change in RelOptRules.xml
   The case is AND/OR(DEFINITELY FALSE, DEFINITELY NULL) -> DEFINITELY FALSE
   done!



-- 
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@calcite.apache.org

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


[GitHub] [calcite] libenchao commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
libenchao commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r958463132


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -151,12 +151,41 @@ public static boolean allStrong(List<RexNode> operands) {
 
   /** Returns whether an expression is definitely not true. */
   public boolean isNotTrue(RexNode node) {
+    return isPredicateNotTrue(node) || isNull(node);

Review Comment:
   I'm still not sure why we cannot merge `isNotTrue` and `isPredicateNotTrue` like below:
   
   ```
     public boolean isNotTrue(RexNode node) {
       switch (node.getKind()) {
       //TODO Enrich with more possible cases?
       case IS_NOT_NULL:
         return isNull(((RexCall) node).getOperands().get(0));
       case OR:
         return allNotTrue(((RexCall) node).getOperands());
       case AND:
         return anyNotTrue(((RexCall) node).getOperands());
       default:
         return isNull(node);
       }
     }
   
     /** Returns whether all expressions in a list are definitely not true. */
     private boolean allNotTrue(List<RexNode> operands) {
       for (RexNode operand : operands) {
         if (!isNotTrue(operand)) {
           return false;
         }
       }
       return true;
     }
   
     /** Returns whether any expressions in a list are definitely not true. */
     private boolean anyNotTrue(List<RexNode> operands) {
       for (RexNode operand : operands) {
         if (isNotTrue(operand)) {
           return true;
         }
       }
       return false;
     }
   ```



-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r957406521


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -149,14 +149,45 @@ public static boolean allStrong(List<RexNode> operands) {
     return operands.stream().allMatch(Strong::isStrong);
   }
 
-  /** Returns whether an expression is definitely not true. */
+  /** Returns whether an expression is definitely not true by either it being analyzed to be not
+   * true or null. */
   public boolean isNotTrue(RexNode node) {
+    return isPredicateNotTrue(node) || isNull(node);
+  }
+
+  /** Returns whether an expression is definitely not true. */
+  public boolean isPredicateNotTrue(RexNode node) {

Review Comment:
   We need this method since the methods below (allNotTrue, anyNotTrue) cannot rely on the isNotTrue due to the || isNull call.
   I will make this method private



-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r957408485


##########
core/src/main/java/org/apache/calcite/plan/Strong.java:
##########
@@ -149,14 +149,45 @@ public static boolean allStrong(List<RexNode> operands) {
     return operands.stream().allMatch(Strong::isStrong);
   }
 
-  /** Returns whether an expression is definitely not true. */
+  /** Returns whether an expression is definitely not true by either it being analyzed to be not
+   * true or null. */
   public boolean isNotTrue(RexNode node) {
+    return isPredicateNotTrue(node) || isNull(node);
+  }
+
+  /** Returns whether an expression is definitely not true. */
+  public boolean isPredicateNotTrue(RexNode node) {

Review Comment:
   made private.



-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on PR #2887:
URL: https://github.com/apache/calcite/pull/2887#issuecomment-1232938222

   > @alimans3 Thanks for your patience, the PR lgtm now. However, the CI still fails, could you fix them?
   
   should be fixed now!


-- 
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@calcite.apache.org

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


[GitHub] [calcite] alimans3 commented on a diff in pull request #2887: [CALCITE-5247] FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS NOT NULL OR RHS.C2 IS NOT NULL`

Posted by GitBox <gi...@apache.org>.
alimans3 commented on code in PR #2887:
URL: https://github.com/apache/calcite/pull/2887#discussion_r956711910


##########
core/src/main/java/org/apache/calcite/plan/StrongPredicateAnalyzer.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexNode;
+
+import java.util.List;
+
+/**
+ * Utilities for checking if a predicate is definitely false based on a strong policy.
+ */
+public final class StrongPredicateAnalyzer {

Review Comment:
   Thanks for the remark, done!



-- 
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@calcite.apache.org

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