Mao Jiayi created FLINK-40151:
---------------------------------

             Summary: Align YAML Transform BETWEEN, IN, and LIKE semantics with 
Flink SQL
                 Key: FLINK-40151
                 URL: https://issues.apache.org/jira/browse/FLINK-40151
             Project: Flink
          Issue Type: Improvement
            Reporter: Mao Jiayi


CDC YAML Transform currently does not fully align with Flink SQL semantics for 
boolean expressions involving NULL.

Many comparison-related expressions return Java false when operands are NULL, 
while SQL should return UNKNOWN. This affects comparison predicates, BETWEEN, 
IN, and LIKE.

Examples:
{code:sql}
NULL = 1
NULL <> 1
NULL > 1
NULL BETWEEN 1 AND 3
1 IN (2, NULL)
NULL LIKE 'a%'
{code}

UNKNOWN should be represented as null in projection results. In filter 
expressions, only TRUE should pass; FALSE and UNKNOWN should not pass.

This issue should align the following expressions with Flink SQL semantics:
* comparison operators: =, <>, <, <=, >, >=
* boolean operators needed for three-valued logic: AND, OR, NOT
* BETWEEN / NOT BETWEEN
* IN / NOT IN
* LIKE / NOT LIKE
* LIKE ... ESCAPE
* SIMILAR TO / NOT SIMILAR TO
* IS UNKNOWN / IS NOT UNKNOWN
* IS DISTINCT FROM / IS NOT DISTINCT FROM

CDC currently implements LIKE as Java regex matching. It should be changed to 
SQL LIKE semantics:
* % matches zero or more characters
* _ matches one character
* ESCAPE is supported
* NULL operands return UNKNOWN

This issue is limited to NULL/UNKNOWN semantics for boolean predicates and 
SQL-compatible LIKE/SIMILAR TO behavior. Other scalar function families should 
be handled by separate issues.

Acceptance Criteria:
* NULL comparison results follow SQL three-valued logic.
* BETWEEN, IN, LIKE, and SIMILAR TO preserve UNKNOWN.
* LIKE no longer treats the pattern as Java regex.
* LIKE supports %, _, and ESCAPE according to SQL semantics.
* IS UNKNOWN, IS NOT UNKNOWN, IS DISTINCT FROM, and IS NOT DISTINCT FROM are 
supported.
* YAML Transform specs cover the fixed NULL and LIKE/SIMILAR TO cases.



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

Reply via email to