tuichenchuxin commented on code in PR #4256:
URL: https://github.com/apache/calcite/pull/4256#discussion_r2011131886


##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -859,4 +859,32 @@ private static Consumer<List> mongoChecker(final String... 
expected) {
         .limit(2)
         .returns("STATE=VT; AVG(pop)=26408\nSTATE=AK; AVG(pop)=26856\n");
   }
+
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-2109";>[CALCITE-2109]
+   * Mongo adapter: unable to translate (A AND B) conditional case</a>. */
+  @Test void testTranslateAndInCondition() {
+    assertModel(MODEL)
+        .query("select state, city from zips "
+            + "where city='LEWISTON' and state in ('ME', 'VT') "
+            + "order by state")
+        .queryContains(
+            mongoChecker(
+            "{$match: {$and: [{$or: [{state: \"ME\"}, {state: \"VT\"}]}, 
{city: \"LEWISTON\"}]}}",
+            "{$project: {STATE: '$state', CITY: '$city'}}",
+            "{$sort: {STATE: 1}}"))
+        .returns("STATE=ME; CITY=LEWISTON\n");
+  }
+
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-2109";>[CALCITE-2109]
+   * Mongo adapter: unable to translate (A AND B) conditional case</a>. */
+  @Test void testAndAlwaysFalseCondition() {
+    assertModel(MODEL)
+        .query("select state, city from zips "
+            + "where city='LEWISTON' and 1=0 "

Review Comment:
   > `1=0` makes the condition of this plan disappear in the Enumerable phase. 
This test for this PR should be invalid.
   
   @NobiGo Yes, but in the issue. This case will throw exception, so, I added 
this.
   if you think it's unnecessary, I'll delete it.



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