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

Xiqian Yu resolved FLINK-40337.
-------------------------------
    Fix Version/s: cdc-3.7.0
         Assignee: Mao Jiayi
       Resolution: Fixed

> Preserve operator precedence in generated Janino expressions
> ------------------------------------------------------------
>
>                 Key: FLINK-40337
>                 URL: https://issues.apache.org/jira/browse/FLINK-40337
>             Project: Flink
>          Issue Type: Bug
>          Components: Flink CDC
>            Reporter: Mao Jiayi
>            Assignee: Mao Jiayi
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: cdc-3.7.0
>
>
> When Flink CDC translates a Pipeline transform expression from Calcite SQL 
> nodes to Janino code, {{JaninoCompiler}} constructs {{Java.BinaryOperation}} 
> nodes and serializes them via {{Java.Rvalue#toString()}}. This method 
> concatenates operands directly without considering operator precedence, so 
> parentheses present in the original expression are silently dropped.
> For example, the following expressions all change semantics after code 
> generation:
> {code}
> (a + b) * c    →  a + b * c
> (a OR b) AND c →  a || b && c
> a / (b * c)    →  a / b * c
> a - (b - c)    →  a - b - c
> {code}
> The generated Janino code evaluates with different grouping than the user's 
> original transform expression, producing incorrect results without any error 
> or warning. Expressions without nesting are unaffected.
> *Expected behavior*: the generated code preserves the original expression's 
> semantics — parentheses are retained where grouping matters, and omitted 
> where precedence already guarantees correct evaluation order (e.g. {{a + b * 
> c}} should stay as-is).



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

Reply via email to