-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[FLINK-39424][table] Setting LIKE does not support default escape characters #27920
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ public static String sqlToRegexLike(String sqlPattern, CharSequence escapeStr) { | |
| } | ||
| escapeChar = escapeStr.charAt(0); | ||
| } else { | ||
| escapeChar = '\\'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Au-Miner Could you double check all changes made in ae4eb7d#diff-b2e1701d6c7cae434d495536a397325850d12a59023d320cbad9389aa7d17b2d Don't we also need to restore the other lines SqlLikeUtils. If a character (doesn't need to be the escape charater) is a special regex character, we need to escape it. |
||
| escapeChar = 0; | ||
| } | ||
| return sqlToRegexLike(sqlPattern, escapeChar); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,9 +36,9 @@ void testSqlLike() { | |
| assertThat(SqlLikeUtils.like("abcd", "a.*d", "\\")).isEqualTo(false); | ||
| assertThat(SqlLikeUtils.like("abcde", "%c.e", "\\")).isEqualTo(false); | ||
|
|
||
| // default escape character | ||
| // no default escape character - backslash is treated as a literal character | ||
| assertThat(SqlLikeUtils.like("a-c", "a\\_c")).isEqualTo(false); | ||
| assertThat(SqlLikeUtils.like("a_c", "a\\_c")).isEqualTo(true); | ||
| assertThat(SqlLikeUtils.like("a_c", "a\\_c")).isEqualTo(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add |
||
|
|
||
| // -------------------------------- sqlToRegexLike ---------------------------------------- | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -408,10 +408,10 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { | |
| testAllApis("abcxxxdef".like("%abc%qef%"), "'abcxxxdef' LIKE '%abc%qef%'", "FALSE") | ||
| testAllApis("abcxxxdef".like("abc%qef"), "'abcxxxdef' LIKE 'abc%qef'", "FALSE") | ||
|
|
||
| // reported in FLINK-36100 | ||
| // reported in FLINK-36100 - without ESCAPE clause, '\' is a literal character | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if we have an escape character defined as |
||
| testAllApis("TE_ST".like("%E_S%"), "'TE_ST' LIKE '%E_S%'", "TRUE") | ||
| testAllApis("TE-ST".like("%E_S%"), "'TE-ST' LIKE '%E_S%'", "TRUE") | ||
| testAllApis("TE_ST".like("%E\\_S%"), "'TE_ST' LIKE '%E\\_S%'", "TRUE") | ||
| testAllApis("TE_ST".like("%E\\_S%"), "'TE_ST' LIKE '%E\\_S%'", "FALSE") | ||
| testAllApis("TE-ST".like("%E\\_S%"), "'TE-ST' LIKE '%E\\_S%'", "FALSE") | ||
| } | ||
|
|
||
|
|
@@ -420,10 +420,10 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { | |
| testAllApis(!'f0.like("Th_s%"), "f0 NOT LIKE 'Th_s%'", "FALSE") | ||
| testAllApis(!'f0.like("%is a%"), "f0 NOT LIKE '%is a%'", "FALSE") | ||
|
|
||
| // reported in FLINK-36100 | ||
| // reported in FLINK-36100 - without ESCAPE clause, '\' is a literal character | ||
| testSqlApi("'TE_ST' NOT LIKE '%E_S%'", "FALSE") | ||
| testSqlApi("'TE-ST' NOT LIKE '%E_S%'", "FALSE") | ||
| testSqlApi("'TE_ST' NOT LIKE '%E\\_S%'", "FALSE") | ||
| testSqlApi("'TE_ST' NOT LIKE '%E\\_S%'", "TRUE") | ||
| testSqlApi("'TE-ST' NOT LIKE '%E\\_S%'", "TRUE") | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.