rubenada commented on code in PR #5184:
URL: https://github.com/apache/calcite/pull/5184#discussion_r3835924139
##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -3024,6 +3025,149 @@ trueLiteral, literal(1),
checkSimplifyUnchanged(div(cast(vVarchar(), tInt(false)), nullInt));
}
+ /**
+ * Test cases for <a
href="https://issues.apache.org/jira/browse/CALCITE-7722">[CALCITE-7722]
+ * RexSimplify IS [NOT] NULL on a safe operator with Strong policy ANY and
unsafe operands
+ * can be further simplified</a>.
+ */
+ @Test void testSimplifyIsNotNullDistributesAcrossStrongOpWithLossyCast() {
+ // "(CAST(?0.varchar0):INTEGER + 1) IS NOT NULL" ==> "IS NOT
NULL(CAST(?0.varchar0):INTEGER)"
+ // The outer PLUS is strong AND shallow-safe; distribution keeps the
+ // non-lossless CAST inside the rewrapped IS NOT NULL
+ checkSimplify(
+ isNotNull(plus(cast(vVarchar(), tInt(true)), literal(1))),
+ "IS NOT NULL(CAST(?0.varchar0):INTEGER)");
+
+ // Symmetric IS NULL peel:
+ // "(CAST(?0.varchar0):INTEGER + 1) IS NULL" ==> "IS
NULL(CAST(?0.varchar0):INTEGER)"
+ checkSimplify(
+ isNull(plus(cast(vVarchar(), tInt(true)), literal(1))),
+ "IS NULL(CAST(?0.varchar0):INTEGER)");
+
+ // Confirm this is consistent with same expression without CAST
Review Comment:
It means the CAST of the tests above (which contains similar IS_NOT_NULL on
PLUS expression, but with CAST operand)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]