[FLINK-39396][table] Simplify early return condition in SqlLikeChainC…#27894
Open
Au-Miner wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39396][table] Simplify early return condition in SqlLikeChainC…#27894Au-Miner wants to merge 1 commit intoapache:masterfrom
Au-Miner wants to merge 1 commit intoapache:masterfrom
Conversation
Collaborator
snuyanzin
reviewed
Apr 3, 2026
| DataTypes.STRING(), | ||
| DataTypes.STRING()) | ||
| // Empty strings in pattern or escape | ||
| .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN()) |
Contributor
There was a problem hiding this comment.
what is the reason of this line removal?
snuyanzin
reviewed
Apr 3, 2026
Comment on lines
+152
to
+166
| .testSqlResult("f0 LIKE '' ESCAPE '!'", false, DataTypes.BOOLEAN()) | ||
| .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN()) | ||
| // Escaped _ in quick path: startsWith (BEGIN_PATTERN) | ||
| .testSqlResult("f2 LIKE 'te!_%' ESCAPE '!'", true, DataTypes.BOOLEAN()) | ||
| .testSqlResult("f0 LIKE 'te!_%' ESCAPE '!'", false, DataTypes.BOOLEAN()) | ||
|
|
||
| // Escaped _ in quick path: endsWith (END_PATTERN) | ||
| .testSqlResult("f2 LIKE '%!_st' ESCAPE '!'", true, DataTypes.BOOLEAN()) | ||
|
|
||
| // Escaped _ in quick path: contains (MIDDLE_PATTERN) | ||
| .testSqlResult("f2 LIKE '%!_s%' ESCAPE '!'", true, DataTypes.BOOLEAN()) | ||
|
|
||
| // Escaped _ in quick path: multi-segment (ChainChecker) | ||
| .testSqlResult("f2 LIKE 'te!_%st' ESCAPE '!'", true, DataTypes.BOOLEAN()) | ||
| .testSqlResult("f0 LIKE 'te!_%st' ESCAPE '!'", false, DataTypes.BOOLEAN()) |
Contributor
There was a problem hiding this comment.
does any of this test fail without a fix?
snuyanzin
reviewed
Apr 3, 2026
Comment on lines
48
to
49
| private final boolean leftAnchor; | ||
| private final boolean rightAnchor; |
Contributor
There was a problem hiding this comment.
after this change these 2 fields are used only in constructor
do we still need to have them as fields?
snuyanzin
reviewed
Apr 3, 2026
| private final int endLen; | ||
| private final boolean leftAnchor; | ||
| private final boolean rightAnchor; | ||
| private final boolean emptyPattern; |
Contributor
There was a problem hiding this comment.
Suggested change
| private final boolean emptyPattern; | |
| private final boolean isEmptyPattern; |
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
Simplify the early return condition in
SqlLikeChainChecker.check()by replacing a complex 7-line compound expression with a singleemptyPatternboolean flag, improving readability without changing semantics.Brief change log
emptyPatternfield toSqlLikeChainCheckerand simplified the early return condition tomark < minLen || mark > 0 && emptyPattern_going through all quick path branches inLikeFunctionITCaseVerifying this change
This change is already covered by existing tests in
LikeFunctionITCase.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation