fix: normalize negative-scale BigDecimal parameters before Arrow encoding - #202
Merged
KaviarasuSakthivadivel merged 4 commits intoSep 30, 2026
Merged
Conversation
KaviarasuSakthivadivel
force-pushed
the
fix/negative-scale-decimal-arrow-param
branch
from
September 24, 2026 18:55
5054a3e to
54b0e9e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
============================================
+ Coverage 80.99% 81.11% +0.12%
- Complexity 1726 1735 +9
============================================
Files 123 123
Lines 5051 5063 +12
Branches 524 526 +2
============================================
+ Hits 4091 4107 +16
+ Misses 728 726 -2
+ Partials 232 230 -2
🚀 New features to boost your workflow:
|
mkaufmann
approved these changes
Sep 24, 2026
KaviarasuSakthivadivel
force-pushed
the
fix/negative-scale-decimal-arrow-param
branch
2 times, most recently
from
September 25, 2026 21:08
cc1bc0d to
902982f
Compare
…ding
BigDecimal.stripTrailingZeros() can yield a negative scale (e.g.
new BigDecimal("12345670").stripTrailingZeros() -> scale=-1, precision=7).
That negative scale was carried straight into the Arrow Decimal type
advertised for the bound parameter, which Hyper rejects before
evaluating any SQL ("Invalid scale -1, scale must be between 0 and the
precision"). Rescale any such value to scale >= 0 in
ArrowUtils.toArrowByteArray before building the schema/vectors.
… branches Closes the Codecov patch-coverage gap on ArrowUtils.java by exercising the branches the initial regression test didn't reach: a null binding, a non-BigDecimal-valued binding, and an already-non-negative-scale BigDecimal, all of which must pass through toArrowByteArray unchanged.
- Explain why a null ParameterBinding is reachable (ParameterAccumulator pads skipped positional parameters with null) so the null-check in normalizeDecimalScale isn't mistaken for defensive-only code. - Strengthen the regression test with an exact assertEquals against "12345670", since BigDecimal#compareTo ignores scale.
BigDecimal.precision() can be smaller than scale() for small-magnitude
values with leading zeros after the decimal point (e.g. new
BigDecimal("0.001") -> precision=1, scale=3), violating Hyper's
"0 <= scale <= precision" DECIMAL invariant in the opposite direction
from the negative-scale case already handled. Generalize
normalizeDecimalScale to widen precision to max(precision, scale)
whenever needed, covering both violation directions in one place.
KaviarasuSakthivadivel
force-pushed
the
fix/negative-scale-decimal-arrow-param
branch
from
September 29, 2026 23:36
902982f to
4eff1b5
Compare
mkaufmann
approved these changes
Sep 30, 2026
KaviarasuSakthivadivel
deleted the
fix/negative-scale-decimal-arrow-param
branch
September 30, 2026 17:18
KaviarasuSakthivadivel
pushed a commit
that referenced
this pull request
Sep 30, 2026
🤖 I have created a release *beep* *boop* --- ## [1.1.1](v1.1.0...v1.1.1) (2026-09-30) ### Bug Fixes * normalize negative-scale BigDecimal parameters before Arrow encoding ([#202](#202)) ([e257047](e257047)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
BigDecimal.stripTrailingZeros() can yield a negative scale (e.g. new BigDecimal("12345670").stripTrailingZeros() -> scale=-1, precision=7). That negative scale was carried straight into the Arrow Decimal type advertised for the bound parameter, which Hyper rejects before evaluating any SQL ("Invalid scale -1, scale must be between 0 and the precision"). Rescale any such value to scale >= 0 in ArrowUtils.toArrowByteArray before building the schema/vectors.