Skip to content

[CALCITE-7673] Add support for the LIKE operator to the MongoDB adapter - #5131

Open
xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:mongodb_like_support
Open

[CALCITE-7673] Add support for the LIKE operator to the MongoDB adapter#5131
xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:mongodb_like_support

Conversation

@xuzifu666

Copy link
Copy Markdown
Member

@xuzifu666
xuzifu666 force-pushed the mongodb_like_support branch 2 times, most recently from 0ad29ac to af646e1 Compare July 29, 2026 09:30

@Dwrite Dwrite left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller's switch only registers LIKE, not NOT_LIKE. If NOT LIKE isn't rewritten into NOT(LIKE(...)) earlier in planning, it could also hit the default branch and throw. Suggest adding a city not like 'A%' test to confirm expected behavior.

}

/** Test case for LIKE operator with escape character on percent. */
@Test void testLikeEscapePercent() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}

/** Test case for LIKE operator without a default escape character. */
@Test void testLikeNoDefaultEscape() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@xuzifu666

Copy link
Copy Markdown
Member Author

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

@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Aug 1, 2026
@xuzifu666 xuzifu666 changed the title [CALCITE-7673] MongoDB Adapter can not support LIKE operator [CALCITE-7673] Add support for the LIKE operator to the MongoDB adapter Aug 3, 2026
@xuzifu666
xuzifu666 force-pushed the mongodb_like_support branch from fd3c61c to ce88571 Compare August 3, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants