You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xuzifu666 (via GitHub)" <gi...@apache.org> on 2026/07/29 07:15:24 UTC
[PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
xuzifu666 opened a new pull request, #5131:
URL: https://github.com/apache/calcite/pull/5131
jira: https://issues.apache.org/jira/browse/CALCITE-7673
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] Add support for the LIKE operator to the MongoDB adapter [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5131:
URL: https://github.com/apache/calcite/pull/5131#issuecomment-5162064813
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [76.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #5131:
URL: https://github.com/apache/calcite/pull/5131#issuecomment-5150464948
Thank you for the review, I had added MongoDB adapter support for the SQL LIKE operator, including ESCAPE semantics, regex special-character escaping, and NOT LIKE pushdown. PTAL @Dwrite
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #5131:
URL: https://github.com/apache/calcite/pull/5131#discussion_r3691013081
##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -1178,4 +1178,153 @@ private static Consumer<List> mongoChecker(final String... expected) {
"CITY_SUBSTRING=RA",
"CITY_SUBSTRING=UT");
}
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-7673">[CALCITE-7673]
+ * MongoDB Adapter can not support LIKE operator</a>. */
+ @Test void testLikePrefix() {
+ // Test LIKE on state field - matches states starting with 'A'
+ assertModel(MODEL)
+ .query("select state, city from zips where state like 'A%' order by state")
+ .returnsUnordered(
+ "STATE=AK; CITY=ANCHORAGE",
+ "STATE=AK; CITY=FAIRBANKS",
+ "STATE=AK; CITY=JUNEAU",
+ "STATE=AL; CITY=CENTER POINT",
+ "STATE=AL; CITY=TUSCALOOSA",
+ "STATE=AL; CITY=SOUTHSIDE",
+ "STATE=AR; CITY=CONWAY",
+ "STATE=AR; CITY=GRAVEL RIDGE",
+ "STATE=AR; CITY=JONESBORO",
+ "STATE=AZ; CITY=MESA",
+ "STATE=AZ; CITY=PHOENIX",
+ "STATE=AZ; CITY=YUMA");
+ }
+
+ /** Test case for LIKE operator with suffix pattern (ends with). */
+ @Test void testLikeSuffix() {
+ assertModel(MODEL)
+ .query("select state, city from zips where city like '%TON' order by state, city")
+ .limit(5)
+ .returnsOrdered(
+ "STATE=DC; CITY=WASHINGTON",
+ "STATE=KY; CITY=HATTON",
+ "STATE=MA; CITY=BROCKTON",
+ "STATE=ME; CITY=LEWISTON",
+ "STATE=MN; CITY=NEW BRIGHTON");
+ }
+
+ /** Test case for LIKE operator with contains pattern. */
+ @Test void testLikeContains() {
+ assertModel(MODEL)
+ .query("select state, city from zips where city like '%ING%' order by state")
+ .limit(5)
+ .returnsOrdered(
+ "STATE=DC; CITY=WASHINGTON",
+ "STATE=MA; CITY=FRAMINGHAM",
+ "STATE=MO; CITY=JENNINGS",
+ "STATE=MT; CITY=BILLINGS",
+ "STATE=NC; CITY=LEXINGTON");
+ }
+
+ /** Test case for LIKE operator with single character wildcard. */
+ @Test void testLikeSingleChar() {
+ // Pattern 'NEW ______' matches cities starting with 'NEW ' followed by exactly 6 characters
+ // NEW IBERIA: "NEW " + "IBERIA" (6 chars) = matches
+ // NEW ORLEANS: "NEW " + "ORLEANS" (7 chars) = does not match
+ // NEW YORK: "NEW " + "YORK" (4 chars) = does not match
+ assertModel(MODEL)
+ .query("select city, state from zips where city like 'NEW ______' order by city")
+ .returnsOrdered(
+ "CITY=NEW IBERIA; STATE=LA");
+ }
+
+ /** Test case for LIKE operator combined with other filters. */
+ @Test void testLikeCombinedWithOtherFilters() {
+ assertModel(MODEL)
+ .query("select city, state from zips where city like 'L%' and state = 'CA' order by city")
+ .returnsOrdered(
+ "CITY=LOS ANGELES; STATE=CA");
+ }
+
+ /** Test case for LIKE operator verifying the generated MongoDB regex. */
+ @Test void testLikeGeneratedRegex() {
+ assertModel(MODEL)
+ .query("select state from zips where city like 'A%'")
+ .queryContains(
+ mongoChecker(
+ "{$match: {city: {$regex: '^A.*$'}}}",
+ "{$project: {STATE: '$state'}}"))
+ .returnsUnordered(
+ "STATE=AK",
+ "STATE=IA",
+ "STATE=SC",
+ "STATE=SD",
+ "STATE=TX");
+ }
+
+ /** Test case for LIKE operator with escape character on underscore. */
+ @Test void testLikeEscapeUnderscore() {
+ // Without escape, '_' matches a single character.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLY_'")
+ .returnsUnordered("CITY=BROOKLYN");
+ // With escape, '_' is a literal character and does not match BROOKLYN.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLY\\_' ESCAPE '\\'")
+ .returnsUnordered();
+ }
+
+ /** Test case for LIKE operator with escape character on percent. */
+ @Test void testLikeEscapePercent() {
Review Comment:
Should you add some NOT LIKE test cases? The switch statement in the caller only handles LIKE, not NOT_LIKE — if NOT LIKE isn't rewritten to NOT(LIKE(...)) before reaching this code, it may fall into the default branch and throw an AssertionError. Worth adding a test like city not like 'A%' to confirm the behavior.
##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -1178,4 +1178,153 @@ private static Consumer<List> mongoChecker(final String... expected) {
"CITY_SUBSTRING=RA",
"CITY_SUBSTRING=UT");
}
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-7673">[CALCITE-7673]
+ * MongoDB Adapter can not support LIKE operator</a>. */
+ @Test void testLikePrefix() {
+ // Test LIKE on state field - matches states starting with 'A'
+ assertModel(MODEL)
+ .query("select state, city from zips where state like 'A%' order by state")
+ .returnsUnordered(
+ "STATE=AK; CITY=ANCHORAGE",
+ "STATE=AK; CITY=FAIRBANKS",
+ "STATE=AK; CITY=JUNEAU",
+ "STATE=AL; CITY=CENTER POINT",
+ "STATE=AL; CITY=TUSCALOOSA",
+ "STATE=AL; CITY=SOUTHSIDE",
+ "STATE=AR; CITY=CONWAY",
+ "STATE=AR; CITY=GRAVEL RIDGE",
+ "STATE=AR; CITY=JONESBORO",
+ "STATE=AZ; CITY=MESA",
+ "STATE=AZ; CITY=PHOENIX",
+ "STATE=AZ; CITY=YUMA");
+ }
+
+ /** Test case for LIKE operator with suffix pattern (ends with). */
+ @Test void testLikeSuffix() {
+ assertModel(MODEL)
+ .query("select state, city from zips where city like '%TON' order by state, city")
+ .limit(5)
+ .returnsOrdered(
+ "STATE=DC; CITY=WASHINGTON",
+ "STATE=KY; CITY=HATTON",
+ "STATE=MA; CITY=BROCKTON",
+ "STATE=ME; CITY=LEWISTON",
+ "STATE=MN; CITY=NEW BRIGHTON");
+ }
+
+ /** Test case for LIKE operator with contains pattern. */
+ @Test void testLikeContains() {
+ assertModel(MODEL)
+ .query("select state, city from zips where city like '%ING%' order by state")
+ .limit(5)
+ .returnsOrdered(
+ "STATE=DC; CITY=WASHINGTON",
+ "STATE=MA; CITY=FRAMINGHAM",
+ "STATE=MO; CITY=JENNINGS",
+ "STATE=MT; CITY=BILLINGS",
+ "STATE=NC; CITY=LEXINGTON");
+ }
+
+ /** Test case for LIKE operator with single character wildcard. */
+ @Test void testLikeSingleChar() {
+ // Pattern 'NEW ______' matches cities starting with 'NEW ' followed by exactly 6 characters
+ // NEW IBERIA: "NEW " + "IBERIA" (6 chars) = matches
+ // NEW ORLEANS: "NEW " + "ORLEANS" (7 chars) = does not match
+ // NEW YORK: "NEW " + "YORK" (4 chars) = does not match
+ assertModel(MODEL)
+ .query("select city, state from zips where city like 'NEW ______' order by city")
+ .returnsOrdered(
+ "CITY=NEW IBERIA; STATE=LA");
+ }
+
+ /** Test case for LIKE operator combined with other filters. */
+ @Test void testLikeCombinedWithOtherFilters() {
+ assertModel(MODEL)
+ .query("select city, state from zips where city like 'L%' and state = 'CA' order by city")
+ .returnsOrdered(
+ "CITY=LOS ANGELES; STATE=CA");
+ }
+
+ /** Test case for LIKE operator verifying the generated MongoDB regex. */
+ @Test void testLikeGeneratedRegex() {
+ assertModel(MODEL)
+ .query("select state from zips where city like 'A%'")
+ .queryContains(
+ mongoChecker(
+ "{$match: {city: {$regex: '^A.*$'}}}",
+ "{$project: {STATE: '$state'}}"))
+ .returnsUnordered(
+ "STATE=AK",
+ "STATE=IA",
+ "STATE=SC",
+ "STATE=SD",
+ "STATE=TX");
+ }
+
+ /** Test case for LIKE operator with escape character on underscore. */
+ @Test void testLikeEscapeUnderscore() {
+ // Without escape, '_' matches a single character.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLY_'")
+ .returnsUnordered("CITY=BROOKLYN");
+ // With escape, '_' is a literal character and does not match BROOKLYN.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLY\\_' ESCAPE '\\'")
+ .returnsUnordered();
+ }
+
+ /** Test case for LIKE operator with escape character on percent. */
+ @Test void testLikeEscapePercent() {
+ // Without escape, '%' matches zero or more characters.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLYN%'")
+ .returnsUnordered("CITY=BROOKLYN");
+ // With escape, '%' is a literal character and does not match BROOKLYN.
+ assertModel(MODEL)
+ .query("select city from zips where city like 'BROOKLYN\\%' ESCAPE '\\'")
+ .returnsUnordered();
+ }
+
+ /** Test case for LIKE operator without a default escape character. */
+ @Test void testLikeNoDefaultEscape() {
Review Comment:
TranslateLike explicitly handles case ITEM: (nested field / map access), but all 12 current tests exercise only the INPUT_REF path. Since this branch is dedicated code, it's currently completely unverified. Suggest adding at least one case like _MAP['city'] like 'A%' to exercise 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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] Add support for the LIKE operator to the MongoDB adapter [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 merged PR #5131:
URL: https://github.com/apache/calcite/pull/5131
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5131:
URL: https://github.com/apache/calcite/pull/5131#issuecomment-5114700726
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [75.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5131:
URL: https://github.com/apache/calcite/pull/5131#issuecomment-5116310782
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [75.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7673] MongoDB Adapter can not support LIKE operator [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5131:
URL: https://github.com/apache/calcite/pull/5131#issuecomment-5151203021
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5131&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [76.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5131&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5131)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org