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 2021/06/25 23:54:02 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #2282: [CALCITE-4420] Some simple arithmetic operations can be simplified

vlsi commented on a change in pull request #2282:
URL: https://github.com/apache/calcite/pull/2282#discussion_r659086697



##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -3224,4 +3224,25 @@ private SqlSpecialOperatorWithPolicy(String name, SqlKind kind, int prec, boolea
   @Test void testSimplifyVarbinary() {
     checkSimplifyUnchanged(cast(cast(vInt(), tVarchar(true, 100)), tVarbinary(true)));
   }
+
+  @Test void testSimplifySimpleArithmetic() {
+    RexNode a = vIntNotNull(1);
+    RexNode zero = literal(0);
+    RexNode one = literal(1);
+
+    RexNode b = vDecimalNotNull(2);
+    RexNode half = literal(new BigDecimal(0.5), b.getType());
+
+    checkSimplify(add(a, zero), "?0.notNullInt1");

Review comment:
       Could you please add a test like `add(zero, sub(vInt(0), vInt(0)))`?
   The expression should evaluate to null in case `vInt(0)` is 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