Repository navigation
Conversation
…c with numeric literals When the result type of a binary arithmetic expression is DECIMAL, the operation is routed to ArithmeticFunctions.plus/minus/times/divides, which only accept (BigDecimal, BigDecimal). Numeric literals such as 1.13 were parsed by Janino as double and non-DECIMAL columns are boxed primitives, so expressions like `price * 1.13` or `cnt * 1.5` passed schema derivation but failed on the first event with "No applicable constructor/method found". Align every operand of a DECIMAL-typed arithmetic expression to BigDecimal. DECIMAL operands are untouched, decimal literals are built from their exact text via castToBigDecimal (never from a double), and integral operands are converted with castToBigDecimal(x, 38, 0).
xxntti3n
force-pushed
the
fix/FLINK-41105-decimal-literal-arith
branch
from
November 13, 2026 15:53
4e30381 to
6d11966
Compare
…tegral or literal dividend ArithmeticFunctions.divides keeps the scale of its dividend, so an operand cast with scale 0 (integral column/literal) or at its own scale (decimal literal, DECIMAL column) truncated the quotient. Cast operands to the scale of the derived result type instead, and cover the cases in PostTransformOperatorTest.
…hmetic with numeric literals Runs transform projections such as decimal_c * 1.13, int_c / 1.5 and 1.5 / decimal_c through the Values source -> transform -> Values sink pipeline on a MiniCluster and asserts the emitted values. Also apply spotless formatting to JaninoCompiler.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Fixes FLINK-41105: a transform projection such as
price * 1.13(DECIMAL column × numeric literal) passes schema derivation but fails on the firstDataChangeEventwith a JaninoCompileException(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.generateBinaryOperationroutes+ - * /toArithmeticFunctions.plus/minus/times/divides, which only have(BigDecimal, BigDecimal)for DECIMAL. A literal like1.13is parsed by Janino asdouble(2asint), and INT/BIGINT columns are boxed primitives, so no overload matches.Brief change log
JaninoCompiler: in the DECIMAL-result branch ofgenerateBinaryOperation, align each operand toBigDecimalvia a newalignOperandToBigDecimal:/, which is widened to the result scale;castToBigDecimal("1.13", p, s), never from adouble, so no binary floating-point error. A literal dividend is widened to the result scale;castToBigDecimal(x, 38, <result scale>).ArithmeticFunctions.divideskeeps the scale of its dividend, so casting at scale 0 (or at the literal's own scale) truncatedcolInt / 1.5,1 / colDecimal,1.5 / colDecimalandcolDecimal / 3.Verifying this change
This change added tests and can be verified as follows:
PostTransformOperatorTest#testDecimalArithmeticWithNumericLiteral(19 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, DECIMAL x DECIMAL, plus division cases with an integral or decimal dividend (colInt / 1.5,1 / colDecimal,1.5 / colDecimal,colDecimal / 3). Without the fix the multiplication/addition/subtraction cases fail with theCompileExceptionabove, and the division cases return truncated quotients.FlinkPipelineTransformITCase#testDecimalArithmeticWithNumericLiteral: runs 10 projections through Values source -> transform -> Values sink on a MiniCluster. On the code before this PR 10 of 12 cases fail; with the fix they pass.spotless:checkandcheckstyle:checkpass forflink-cdc-runtimeandflink-cdc-composer.FlinkPipelineUdfITCase(52),FlinkPipelineTransformITCase(82),TransformParserTestandPostTransformOperatorTestpass on JDK 17.Out of scope: the
%(MOD) operator on DECIMAL still fails at type inference (validated INTEGER vs converted DECIMAL). It is a separate problem and is not changed here.Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Sonnet 5.5)
I reviewed the change and the test results myself.