xxntti3n opened a new pull request, #4624:
URL: https://github.com/apache/flink-cdc/pull/4624

   ## What is the purpose of this pull request?
   
   Fixes [FLINK-41105](https://issues.apache.org/jira/browse/FLINK-41105): a 
transform projection such as `price * 1.13` (DECIMAL column × numeric literal) 
passes schema derivation but fails on the first `DataChangeEvent` with a Janino 
`CompileException` (`No applicable constructor/method found for actual 
parameters "java.math.BigDecimal, double"`), so the job restarts forever.
   
   Root cause: when the derived result type is DECIMAL, 
`JaninoCompiler.generateBinaryOperation` routes `+ - * /` to 
`ArithmeticFunctions.plus/minus/times/divides`, which only have `(BigDecimal, 
BigDecimal)` for DECIMAL. A literal like `1.13` is parsed by Janino as `double` 
(`2` as `int`), and INT/BIGINT columns are boxed primitives, so no overload 
matches.
   
   ## Brief change log
   
   - `JaninoCompiler`: in the DECIMAL-result branch of 
`generateBinaryOperation`, align each operand to `BigDecimal` via a new 
`alignOperandToBigDecimal`:
     - operands already typed DECIMAL (columns, sub-expressions) are left 
untouched;
     - decimal literals are built from their exact text with 
`castToBigDecimal("1.13", p, s)`, never from a `double`, so no binary 
floating-point error;
     - integral operands (INT/BIGINT columns, integer literals) go through 
`castToBigDecimal(x, 38, 0)`.
   - Non-DECIMAL expressions and existing overload sets are unchanged.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added `PostTransformOperatorTest#testDecimalArithmeticWithNumericLiteral` 
(10 parameterized cases through the real operator): `colDecimal * 1.13`, `* 2`, 
`+ 1.5`, `- 1.5`, `/ 2`, `colInt * 1.5`, literal on the left, negative literal, 
nested expression, and DECIMAL × DECIMAL. The first 7 cases fail with the 
`CompileException` above without the fix and pass with it.
   - Also ran `JaninoCompilerTest`, `PreTransformOperatorTest`, 
`UnifiedTransformOperatorTest`, `TransformExpressionCompilerTest`: all green.
   - Not run: the full `flink-cdc-runtime` module and e2e tests. 5 UDF-related 
tests in `PostTransformOperatorTest` / `TransformParserTest` fail locally with 
`ClassNotFoundException` for `flink-cdc-pipeline-udf-examples` classes (that 
module could not be built offline); they fail the same way without this change.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Sonnet 5.5)
   
   I reviewed the change and the test results myself.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to