You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Qilong Wang (Jira)" <ji...@apache.org> on 2026/04/03 08:11:00 UTC

[jira] [Created] (FLINK-39396) Simplify early return condition in SqlLikeChainChecker.check()

Qilong Wang created FLINK-39396:
-----------------------------------

             Summary: Simplify early return condition in SqlLikeChainChecker.check()
                 Key: FLINK-39396
                 URL: https://issues.apache.org/jira/browse/FLINK-39396
             Project: Flink
          Issue Type: Technical Debt
          Components: Table SQL / Planner
    Affects Versions: 2.3.0
            Reporter: Qilong Wang
             Fix For: 2.3.0


Problem
The early return condition in SqlLikeChainChecker.check() is overly complex and hard to understand:
{code:java}
if (mark < minLen
        || beginPattern == null
                && endPattern == null
                && middlePatterns.length == 0
                && mark > 0
                && (leftAnchor || rightAnchor)) {
    return false;
}{code}
The second branch (after ||) combines 5 sub-conditions, but through analysis, the only scenario that satisfies all of them is when the pattern is an empty string and the input is non-empty:
beginPattern == null && endPattern == null && middlePatterns.length == 0: no literal segments were parsed.
leftAnchor || rightAnchor: the pattern does not start or end with %.
The only pattern that produces zero tokens from StringTokenizer AND has at least one anchor is the empty string "".
The original comment also reflects this confusion: "the pattern is empty (or anchored with no literals)" — the two cases described by "or" are actually the same case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)