You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/04/03 09:54:00 UTC

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

     [ https://issues.apache.org/jira/browse/FLINK-39396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated FLINK-39396:
-----------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Priority: Major
>              Labels: pull-request-available
>             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)