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 2019/10/28 09:57:15 UTC

[GitHub] [calcite] DonnyZone commented on a change in pull request #1540: [CALCITE-3433] EQUALS operator between date/timestamp types returns false if the type is nullable

DonnyZone commented on a change in pull request #1540: [CALCITE-3433] EQUALS operator between date/timestamp types returns false if the type is nullable
URL: https://github.com/apache/calcite/pull/1540#discussion_r339477862
 
 

 ##########
 File path: linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java
 ##########
 @@ -255,11 +255,40 @@ void accept(ExpressionWriter writer, int lprec, int rprec) {
     if (writer.requireParentheses(this, lprec, rprec)) {
       return;
     }
+    // When comparing two primitive boxing class (e.g., Long x, Long y),
+    // if "x" or "y" is not a constant null expression, we should
+    // call "Objects.equals(x, y)", rather than "x == y"
+    if (nodeType == ExpressionType.Equal
+        || nodeType == ExpressionType.NotEqual) {
+      Primitive boxPrimitive0 = Primitive.ofBox(expression0.getType());
+      Primitive boxPrimitive1 = Primitive.ofBox(expression1.getType());
+      if (boxPrimitive0 != null && boxPrimitive1 != null
+          && !isConstantNullExpression(expression0)
+          && !isConstantNullExpression(expression1)) {
 
 Review comment:
   Do you mean that we should keep the evaluation logic and codegen logic as same?

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


With regards,
Apache Git Services