Skip to content

[FLINK-39396][table] Simplify early return condition in SqlLikeChainC…#27894

Open
Au-Miner wants to merge 1 commit intoapache:masterfrom
Au-Miner:FLINK-39396
Open

[FLINK-39396][table] Simplify early return condition in SqlLikeChainC…#27894
Au-Miner wants to merge 1 commit intoapache:masterfrom
Au-Miner:FLINK-39396

Conversation

@Au-Miner
Copy link
Copy Markdown
Contributor

@Au-Miner Au-Miner commented Apr 3, 2026

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

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 3, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

DataTypes.STRING(),
DataTypes.STRING())
// Empty strings in pattern or escape
.testSqlResult("f0 LIKE 'test\"end' ESCAPE ''", false, DataTypes.BOOLEAN())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason of this line removal?

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())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does any of this test fail without a fix?

Comment on lines 48 to 49
private final boolean leftAnchor;
private final boolean rightAnchor;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this change these 2 fields are used only in constructor
do we still need to have them as fields?

private final int endLen;
private final boolean leftAnchor;
private final boolean rightAnchor;
private final boolean emptyPattern;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final boolean emptyPattern;
private final boolean isEmptyPattern;

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.

3 participants