You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Mao Jiayi (Jira)" <ji...@apache.org> on 2026/08/05 11:58:00 UTC

[jira] [Created] (FLINK-40337) Preserve operator precedence in generated Janino expressions

Mao Jiayi created FLINK-40337:
---------------------------------

             Summary: 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


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)