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:29:41 UTC

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

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

 ##########
 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:
   I think we should move this logic into [1]
   
   [1] https://github.com/apache/calcite/blob/08dfd170ae91162ffb082f48c4186952955a73d2/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java#L103
   

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