[FLINK-39424][table] Setting LIKE does not support default escape characters#27920
Open
Au-Miner wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39424][table] Setting LIKE does not support default escape characters#27920Au-Miner wants to merge 1 commit intoapache:masterfrom
Au-Miner wants to merge 1 commit intoapache:masterfrom
Conversation
Collaborator
twalthr
reviewed
Apr 13, 2026
| } | ||
| escapeChar = escapeStr.charAt(0); | ||
| } else { | ||
| escapeChar = '\\'; |
Contributor
There was a problem hiding this comment.
@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.
davidradl
reviewed
Apr 13, 2026
davidradl
reviewed
Apr 13, 2026
| // 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.
can we add
assertThat(SqlLikeUtils.like("a\\_c", "a\\_c")).isEqualTo(true);
davidradl
reviewed
Apr 13, 2026
| 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.
what happens if we have an escape character defined as _ or % or * . Can we test that these will be rejected?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Remove the default escape character \ in LIKE when no ESCAPE clause is specified. Since Flink's string literal also does not support backslashes, the default escape character causes confusion.
Brief change log
Verifying this change
This change is verified by FlinkSqlLikeUtilsTest.java and ScalarFunctionsTest.scala (#testLike / #testLikeWithEscape).
Does this pull request potentially affect one of the following parts:
@Public(Evolving): yesDocumentation