You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Au-Miner (via GitHub)" <gi...@apache.org> on 2026/04/03 09:53:10 UTC
[PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Au-Miner opened a new pull request, #27894:
URL: https://github.com/apache/flink/pull/27894
## 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 single `emptyPattern` boolean flag, improving readability without changing semantics.
## Brief change log
- Added `emptyPattern` field to `SqlLikeChainChecker` and simplified the early return condition to `mark < minLen || mark > 0 && emptyPattern`
- Added test cases for escaped `_` going through all quick path branches in `LikeFunctionITCase`
## Verifying this change
This change is already covered by existing tests in `LikeFunctionITCase`.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3033491365
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/LikeFunctionITCase.java:
##########
@@ -148,8 +148,22 @@ private Stream<TestSetSpec> withEscape() {
DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
- .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
.testSqlResult("f0 LIKE '' ESCAPE ''", false, DataTypes.BOOLEAN())
+ .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())
Review Comment:
does any of this test fail without a fix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on PR #27894:
URL: https://github.com/apache/flink/pull/27894#issuecomment-4192556163
Thanks for the review, let me give some comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #27894:
URL: https://github.com/apache/flink/pull/27894
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27894:
URL: https://github.com/apache/flink/pull/27894#issuecomment-4182824024
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "7134b14ad5fe68344dc0ab2db41da4e863722343",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "7134b14ad5fe68344dc0ab2db41da4e863722343",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 7134b14ad5fe68344dc0ab2db41da4e863722343 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3039763920
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlLikeChainChecker.java:
##########
@@ -47,11 +47,13 @@ public class SqlLikeChainChecker {
private final int endLen;
private final boolean leftAnchor;
private final boolean rightAnchor;
Review Comment:
I don't think this is necessary, they have already been moved to `SqlLikeChainChecker`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3039765928
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlLikeChainChecker.java:
##########
@@ -47,11 +47,13 @@ public class SqlLikeChainChecker {
private final int endLen;
private final boolean leftAnchor;
private final boolean rightAnchor;
+ private final boolean emptyPattern;
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3033489564
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/LikeFunctionITCase.java:
##########
@@ -148,8 +148,22 @@ private Stream<TestSetSpec> withEscape() {
DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
- .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
Review Comment:
what is the reason of this line removal?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3039752710
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/LikeFunctionITCase.java:
##########
@@ -148,8 +148,22 @@ private Stream<TestSetSpec> withEscape() {
DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
- .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
.testSqlResult("f0 LIKE '' ESCAPE ''", false, DataTypes.BOOLEAN())
+ .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())
Review Comment:
At present, this is not a bug fix, but a technical debt
These tests are designed to increase the coverage of the tests and cover the modified parts
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3039752710
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/LikeFunctionITCase.java:
##########
@@ -148,8 +148,22 @@ private Stream<TestSetSpec> withEscape() {
DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
- .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
.testSqlResult("f0 LIKE '' ESCAPE ''", false, DataTypes.BOOLEAN())
+ .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())
Review Comment:
At present, this is not a bug fix, but a technical debt
These tests are designed to increase the coverage of the tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3033493766
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlLikeChainChecker.java:
##########
@@ -47,11 +47,13 @@ public class SqlLikeChainChecker {
private final int endLen;
private final boolean leftAnchor;
private final boolean rightAnchor;
Review Comment:
after this change these 2 fields are used only in constructor
do we still need to have them as fields?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3033495323
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlLikeChainChecker.java:
##########
@@ -47,11 +47,13 @@ public class SqlLikeChainChecker {
private final int endLen;
private final boolean leftAnchor;
private final boolean rightAnchor;
+ private final boolean emptyPattern;
Review Comment:
```suggestion
private final boolean isEmptyPattern;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39396][table] Simplify early return condition in SqlLikeChainC… [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #27894:
URL: https://github.com/apache/flink/pull/27894#discussion_r3039736715
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/LikeFunctionITCase.java:
##########
@@ -148,8 +148,22 @@ private Stream<TestSetSpec> withEscape() {
DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
- .testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
Review Comment:
This line was not deleted, but placed on line 153
This is arranged according to the pattern-ESCAPE-escape format, with three tests being
> empty ESCAPE empty
> empty ESCAPE non-empty
> non-empty ESCAPE empty
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org