vvysotskyi commented on a change in pull request #1551: [CALCITE-3457] 
RexSimplify incorrectly simplifies IS NOT NULL operator with ITEM call
URL: https://github.com/apache/calcite/pull/1551#discussion_r341846761
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
 ##########
 @@ -821,6 +823,49 @@ private RexNode simplifyIsNull(RexNode a) {
     }
   }
 
+  /**
+   * Validates strong policy for specified {@link RexNode} rex node.
+   *
+   * @param rexNode rex node whose strong policy should be validated.
+   */
+  private void validateStrongPolicy(RexNode rexNode) {
+    if (hasCustomNullabilityRules(rexNode.getKind())) {
+      return;
+    }
+    switch (Strong.policy(rexNode.getKind())) {
+    case NOT_NULL:
+      assert !rexNode.getType().isNullable();
+      break;
+    case ANY:
+      List<RexNode> operands = ((RexCall) rexNode).getOperands();
+      if (rexNode.getType().isNullable()) {
+        assert operands.stream()
+            .map(RexNode::getType)
+            .anyMatch(RelDataType::isNullable);
+      } else {
+        assert operands.stream()
+            .map(RexNode::getType)
+            .noneMatch(RelDataType::isNullable);
+      }
+    }
+  }
+
+  /**
+   * Returns {@code true} if specified {@link SqlKind} sql kind has custom 
nullability rules.
 
 Review comment:
   Yes, thats correct. I have corrected JavaDoc and provided an example with 
CAST there.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to