Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(clickhouse): map RegexpILike to match #2407

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

georgesittas
Copy link
Collaborator

Fixes #2406

Couldn't find another variant for case-insensitive matching. There's ILIKE but I don't think it works with regex patterns?

Reference: https://clickhouse.com/docs/en/sql-reference/functions/string-search-functions

@tobymao
Copy link
Owner

tobymao commented Oct 14, 2023

don't you need to modify the regex to add case sensitivy?

@georgesittas
Copy link
Collaborator Author

Ah I missed that, thanks. I can fix it a bit later unless you wanna take this to the finish line.

@tobymao
Copy link
Owner

tobymao commented Oct 14, 2023

https://github.com/google/re2/wiki/Syntax maybe regex on the regx to see if there's a section (?flag)

@georgesittas
Copy link
Collaborator Author

I was playing around in https://play.clickhouse.com/play trying to understand how ?i flag works and realized that it needs to be prepended instead of appended. This is also demonstrated in the test cases here: https://github.com/ClickHouse/ClickHouse/pull/11649/files. Thus I decided to solve this by always concatenating '(?i)' with the haystack. The two test cases I added produce equivalent results in Postgres and ClickHouse. I also checked the case where there are two (?i) flags in the regex and it seems like the second one is a no-op.

cc @samuelcolvin

@tobymao tobymao merged commit f970f7c into main Oct 16, 2023
5 checks passed
@tobymao tobymao deleted the jo/clickhouse_regexpilike_to_match branch October 16, 2023 15:30
@samuelcolvin
Copy link
Contributor

Awesome, thanks for catching that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REGEXP_I_LIKE method doesn't exist in ClickHouse
3 participants