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


##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -919,4 +919,72 @@ private static Consumer<List> mongoChecker(final String... 
expected) {
                 "{$sort: {STATE: 1}}"))
         .returns("STATE=ME; CITY=LEWISTON\nSTATE=VT; CITY=BRATTLEBORO\n");
   }
+
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-7079";>[CALCITE-7079]
+   * Mongo adapter: unable to translate  (A <> 'a' and A <> 'b') conditional 
case  </a>. */
+  @Test void testMultiNeFilterContition() {
+    assertModel(MODEL)
+        .query("select city, state from zips where city <> 'ABERDEEN' and city 
<> 'AIKEN'  "
+            + "order by city")
+        .limit(3)
+        .queryContains(
+            mongoChecker(
+                "{$match: {city: {$nin: [\"ABERDEEN\", \"AIKEN\"]}}}",
+                "{$project: {CITY: '$city', STATE: '$state'}}",
+                "{$sort: {CITY: 1}}"))
+        .returnsOrdered("CITY=ALTON; STATE=TX",
+            "CITY=AMES; STATE=IA",
+            "CITY=ANCHORAGE; STATE=AK");
+
+    assertModel(MODEL)
+        .query("select city, state from zips where city <> 'ABERDEEN' and city 
<> 'AIKEN'  "
+            + "or (state <> 'IA' and state <> 'TX') order by city")
+        .limit(3)
+        .queryContains(
+            mongoChecker(
+                "{$match: {$or: [{city: {$nin: [\"ABERDEEN\", \"AIKEN\"]}}, 
{state: {$nin: [\"IA\", \"TX\"]}}]}}",
+                "{$project: {CITY: '$city', STATE: '$state'}}",
+                "{$sort: {CITY: 1}}"))
+        .returnsOrdered("CITY=ABERDEEN; STATE=SD",
+            "CITY=AIKEN; STATE=SC",
+            "CITY=ALTON; STATE=TX");
+
+    assertModel(MODEL)
+        .query("select city, state from zips where city <> 'ABERDEEN' and city 
<> 'AIKEN'  "
+            + "and state <> 'IA' order by city")
+        .limit(3)
+        .queryContains(
+            mongoChecker(
+                "{$match: {city: {$nin: [\"ABERDEEN\", \"AIKEN\"]}, state: 
{$ne: \"IA\"}}}",
+                "{$project: {CITY: '$city', STATE: '$state'}}",
+                "{$sort: {CITY: 1}}"))
+        .returnsOrdered("CITY=ALTON; STATE=TX",
+            "CITY=ANCHORAGE; STATE=AK",
+            "CITY=BALTIMORE; STATE=MD");
+
+    assertModel(MODEL)
+        .query("select city, state from zips where city <> 'ABERDEEN' and city 
<> 'AIKEN'  "
+            + "and (state <> 'IA' or state <> 'TX') order by city")
+        .limit(3)
+        .queryContains(
+            mongoChecker(
+                "{$match: {city: {$nin: [\"ABERDEEN\", \"AIKEN\"]}, state: 
{$ne: null}}}",
+                "{$project: {CITY: '$city', STATE: '$state'}}",
+                "{$sort: {CITY: 1}}"))
+        .returnsOrdered("CITY=ALTON; STATE=TX",
+            "CITY=AMES; STATE=IA",
+            "CITY=ANCHORAGE; STATE=AK");
+
+    assertModel(MODEL)
+        .query("select city, state from zips where city <> 'ABERDEEN' and city 
<> 'AIKEN'  "
+            + "and state IS NULL order by city")

Review Comment:
   Ok, I will remove this test case.



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