zoov-w commented on code in PR #4452:
URL: https://github.com/apache/calcite/pull/4452#discussion_r2204981262
##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -919,4 +919,77 @@ 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' "
+ + "and city <> 'ALTON' order by city")
+ .limit(3)
+ .queryContains(
+ mongoChecker(
+ "{$match: {city: {$nin: [\"ABERDEEN\", \"AIKEN\",
\"ALTON\"]}}}",
+ "{$project: {CITY: '$city', STATE: '$state'}}",
+ "{$sort: {CITY: 1}}"))
+ .returnsOrdered("CITY=AMES; STATE=IA",
+ "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' and state <> 'TX' order by city")
+ .limit(3)
+ .queryContains(
+ mongoChecker(
+ "{$match: {city: {$nin: [\"ABERDEEN\", \"AIKEN\"]}, state:
{$nin: [\"IA\", \"TX\"]}}}",
Review Comment:
I have tested some case, if condition is: expr1 AND (expr2 OR expr3) ,
then $AND is display. In this test case, $AND hidden because only AND
conjunction multiple expressions, it no affect of other mixed 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]