Bound plain-notation expansion of DECIMAL literals to prevent parse-time OutOfMemoryError - #5223
Open
shoemoney wants to merge 1 commit into
Open
Bound plain-notation expansion of DECIMAL literals to prevent parse-time OutOfMemoryError#5223shoemoney wants to merge 1 commit into
shoemoney wants to merge 1 commit into
Conversation
Contributor
|
The linter won't like your commit message. Have you tried to validate this locally? |
…Primitive.checkOverflow Primitive.checkOverflow calls BigDecimal.toPlainString on a value with scale < 0 without bounding the plain-notation expansion, the same pattern bounded elsewhere in CALCITE-7731. A large negative scale can force toPlainString to materialize gigabytes and OOM. Gate the toPlainString call with isBoundedDecimal, mirroring SqlUtil.isBoundedDecimal in core but inlined in linq4j to avoid a circular linq4j -> core dependency. The bound reads calcite.parser.maxDecimalLiteralPlainDigits (default 10000) and checks precision + abs(scale) <= limit, throwing IllegalArgumentException before allocation if exceeded.
shoemoney
force-pushed
the
fix/calcite-checkoverflow-bounded
branch
from
August 27, 2026 20:25
c9a1bd9 to
c9ed2c6
Compare
Author
|
Fixed, commit message now uses [CALCITE-7731] in c9ed2c6. |
Contributor
|
I have changed your PR title to match |
Contributor
|
Is this really needed? Can we get into a "risky" scenario here, considering the checks introduced in CALCITE-7731 ? |
|
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.



Sibling of CALCITE-7731.
Bug: Primitive.checkOverflow calls BigDecimal.toPlainString on a value with scale < 0 without bounding the plain-notation expansion. A large negative scale can force toPlainString to materialize gigabytes and OOM, same pattern bounded elsewhere in CALCITE-7731.
Fix: Gate the toPlainString call with isBoundedDecimal. This mirrors SqlUtil.isBoundedDecimal in core but is inlined in linq4j to avoid a circular linq4j -> core dependency. The bound reads calcite.parser.maxDecimalLiteralPlainDigits (default 10000) and checks precision + abs(scale) <= limit. If exceeded, throw IllegalArgumentException before allocation.
Evidence: RED->GREEN verified. Both :linq4j:compileJava configurations succeed. Formatter blast radius is one file.