zoov-w commented on code in PR #4452:
URL: https://github.com/apache/calcite/pull/4452#discussion_r2205470714


##########
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 condition is `where city  <> 'a' or city <> 'b'`,  ReduceExpressionsRule 
rewrite conditions to `city IS NOT NULL`, so  `city IS NOT NULL`  converted  to 
`{city: {$exists: true}}`. 
   I think it conflict with  `select city from table where city IS NOT NULL`, 
it should contert to `{$match: {city: {$ne: null}}}, {$project: {CITY: 
'$city'}}`, which is better? 



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to