[
https://issues.apache.org/jira/browse/FLINK-39396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Yuepeng Pan updated FLINK-39396:
--------------------------------
Fix Version/s: 2.4.0
(was: 2.3.0)
> 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.4.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)