This is an automated email from the ASF dual-hosted git repository.
xuzifu666 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new c2cbd8912d Test cases for [CALCITE-4232] Elasticsearch IN Query is not
supported
c2cbd8912d is described below
commit c2cbd8912d593193bb7ebcd2d25836fcb4296d76
Author: Yu Xu <[email protected]>
AuthorDate: Sat May 9 15:51:31 2026 +0800
Test cases for [CALCITE-4232] Elasticsearch IN Query is not supported
---
.../elasticsearch/AggregationAndSortTest.java | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git
a/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/AggregationAndSortTest.java
b/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/AggregationAndSortTest.java
index 9996180ae3..20bcef9d83 100644
---
a/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/AggregationAndSortTest.java
+++
b/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/AggregationAndSortTest.java
@@ -566,4 +566,52 @@ private static Connection
createConnectionWithConformance(String lex, String con
.query("select count(*) from (select cat5, sum(val1) from view group
by cat5) as alias")
.returns("EXPR$0=3\n");
}
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-4232">[CALCITE-4232]
+ * Elasticsearch IN Query is not supported</a>.
+ */
+ @Test void testInPredicate() {
+ // Single value IN
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat1 from view where cat1 in ('a')")
+ .returns("cat1=a\n");
+
+ // IN with non-existing values returns empty result (0 documents)
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat1 from view where cat1 in ('x', 'y', 'z')")
+ .returnsCount(0);
+
+ // Partial match IN
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat1 from view where cat1 in ('a', 'x')")
+ .returns("cat1=a\n");
+
+ // NOT IN all existing values, only null cat1 remains (ES terms behavior)
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat1 from view where cat1 not in ('a', 'b')")
+ .returns("cat1=null\n");
+
+ // Integer type IN
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat5 from view where cat5 in (1, 2)")
+ .returnsUnordered("cat5=1", "cat5=2");
+
+ // IN with integer type and non-existing value returns empty result
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select cat5 from view where cat5 in (999)")
+ .returnsCount(0);
+
+ // Long type IN
+ CalciteAssert.that()
+ .with(AggregationAndSortTest::createConnection)
+ .query("select val1 from view where val1 in (1, 7)")
+ .returnsUnordered("val1=1", "val1=7");
+ }
}