xiedeyantu commented on code in PR #4452:
URL: https://github.com/apache/calcite/pull/4452#discussion_r2206073741


##########
mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoFilter.java:
##########
@@ -267,5 +290,14 @@ private void translateOp2(String op, String name, 
RexLiteral right,
         multimap.put(name, Pair.of(op, right));
       }
     }
+
+    /** Translates is null/is not null to $exists. */
+    private Void translateUnary(RexCall call,
+        Multimap<String, Pair<String, RexLiteral>> multimap, Map<String, 
RexLiteral> eqMap) {
+      boolean isNull = call.getKind() == SqlKind.IS_NULL;
+      final RexNode node = call.operands.get(0);
+      translateBinary2("$exists", node, rexBuilder.makeLiteral(isNull), 
multimap, eqMap);

Review Comment:
   If I understand correctly, if the `city` field exists and is null, then 
`{city: {$exists: true}}` will match successfully, but `{city: {$ne: null}}` 
will not. I don't know much about mongodb, but I think `{city: {$ne: null}}` is 
more appropriate. What do you think? 



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

Reply via email to