danny0405 commented on a change in pull request #1448: [CALCITE-3332] Query 
failed with AssertionError: cannot cast null as class java.math.BigDecima
URL: https://github.com/apache/calcite/pull/1448#discussion_r323074290
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/fun/SqlSubstringFunction.java
 ##########
 @@ -195,8 +195,9 @@ public void unparse(
       final SqlMonotonicity mono0 = call.getOperandMonotonicity(0);
       if ((mono0 != SqlMonotonicity.NOT_MONOTONIC)
           && call.getOperandMonotonicity(1) == SqlMonotonicity.CONSTANT
-          && call.getOperandLiteralValue(1, BigDecimal.class)
-              .equals(BigDecimal.ZERO)
+          && ((call.isOperandNull(1, true))
+              || call.getOperandLiteralValue(1, BigDecimal.class)
+              .equals(BigDecimal.ZERO))
 
 Review comment:
   I don't think the mono0 is still the same when the operand1 is null, that 
means `substring('abc', null)` could returns null, which may breaks the 
monotonicity of operand0.

----------------------------------------------------------------
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