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 2020/11/22 18:34:08 UTC

[GitHub] [calcite] julianhyde commented on a change in pull request #2246: [CALCITE-4377] Fix the return nullability inference during rex simpli…

julianhyde commented on a change in pull request #2246:
URL: https://github.com/apache/calcite/pull/2246#discussion_r528386203



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -900,13 +902,12 @@ private void validateStrongPolicy(RexNode rexNode) {
     case ANY:
       List<RexNode> operands = ((RexCall) rexNode).getOperands();
       if (rexNode.getType().isNullable()) {
-        assert operands.stream()
-            .map(RexNode::getType)
-            .anyMatch(RelDataType::isNullable);
+        // Ignores the nullability change when all the operands are literals
+        // which come from the simplification.
+        assert operands.stream().map(RexNode::getType).anyMatch(RelDataType::isNullable)
+            || operands.stream().allMatch(p -> RexUtil.isLiteral(p, false));

Review comment:
       I agree with @vlsi. We should not change the type inference. In fact, type inference is working perfectly.
   
   I think we should drop the requirement that `RexSimplify` does not change nullability. I know this conflicts with the requirement that `RelOptRule` does not change row type, which is a requirement we want to keep. The solution may be to add a cast (or some other operator) to say 'treat this not-null expression as nullable'.




----------------------------------------------------------------
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:
users@infra.apache.org