Skip to content

fix(calcite): gate checkOverflow toPlainString with isBoundedDecimal - #5223

Open
shoemoney wants to merge 1 commit into
apache:mainfrom
shoemoney:fix/calcite-checkoverflow-bounded
Open

fix(calcite): gate checkOverflow toPlainString with isBoundedDecimal#5223
shoemoney wants to merge 1 commit into
apache:mainfrom
shoemoney:fix/calcite-checkoverflow-bounded

Conversation

@shoemoney

Copy link
Copy Markdown

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.

Fix verified RED->GREEN. Primitive.checkOverflow unbounded toPlainString sibling of CALCITE-7731 at Primitive.java:420
@mihaibudiu

Copy link
Copy Markdown
Contributor

The linter won't like your commit message. Have you tried to validate this locally?
Maybe you should just use 7731 again in the commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants