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

Qilong Wang updated FLINK-39402:
--------------------------------
    Description: 
The LIKE expression uses \ as the default escape character when no ESCAPE 
clause is specified. However, the escaped _ and % behave inconsistently:

```– '\' escapes '{_}' to match a literal '{_}' — correct
SELECT 'TE_ST' LIKE 'TE_ST'   – TRUE

– '\' escapes '%' to match a literal '%' — should be TRUE, but returns FALSE
SELECT 'TE%ST' LIKE 'TE%ST'   – FALSE```

Both _ and % should be treated as escaped literals under the default escape 
character \. The fix unifies escape handling so that % is correctly recognized 
as a literal %, consistent with _.

  was:
The LIKE expression uses \ as the default escape character when no ESCAPE 
clause is specified. However, the escaped \_ and \% behave inconsistently:

-- '\' escapes '_' to match a literal '_' — correct
SELECT 'TE_ST' LIKE 'TE\_ST'   -- TRUE

-- '\' escapes '%' to match a literal '%' — should be TRUE, but returns FALSE
SELECT 'TE%ST' LIKE 'TE\%ST'   -- FALSE

Both \_ and \% should be treated as escaped literals under the default escape 
character \. The fix unifies escape handling so that \% is correctly recognized 
as a literal %, consistent with \_.


> Fix LIKE quick path ignoring default escape character '\'
> ---------------------------------------------------------
>
>                 Key: FLINK-39402
>                 URL: https://issues.apache.org/jira/browse/FLINK-39402
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 2.3.0
>            Reporter: Qilong Wang
>            Priority: Major
>             Fix For: 2.3.0
>
>
> The LIKE expression uses \ as the default escape character when no ESCAPE 
> clause is specified. However, the escaped _ and % behave inconsistently:
> ```– '\' escapes '{_}' to match a literal '{_}' — correct
> SELECT 'TE_ST' LIKE 'TE_ST'   – TRUE
> – '\' escapes '%' to match a literal '%' — should be TRUE, but returns FALSE
> SELECT 'TE%ST' LIKE 'TE%ST'   – FALSE```
> Both _ and % should be treated as escaped literals under the default escape 
> character \. The fix unifies escape handling so that % is correctly 
> recognized as a literal %, consistent with _.



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

Reply via email to