Skip to content

fix(spec): reserve 16 bytes for non-compact decimal in BinaryRow - #791

Merged
JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/binary-row-decimal-16-bytes
Sep 4, 2026
Merged

fix(spec): reserve 16 bytes for non-compact decimal in BinaryRow#791
JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/binary-row-decimal-16-bytes

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

write_decimal_var_len pads the variable-length part to a multiple of 8, but Java
reserves 16 bytes for every non-compact Decimal — AbstractBinaryWriter#writeDecimal
does ensureCapacity(16), zeroes both halves, and advances the cursor by 16
unconditionally.

So whenever the minimal form fits in 8 bytes (|unscaled| < 2^63, e.g.
DECIMAL(38, 18) holding 1.5) Rust writes a row 8 bytes shorter than Java's.
Decoding is unaffected — both sides read the stored (offset, size) — but
hash_code hashes the whole buffer and feeds default_bucket, so the row lands in
a different bucket than in Java.

The existing test uses 1e19, whose 9-byte minimal form already rounded up to 16,
so this case had no coverage.

@JingsongLi
JingsongLi merged commit dda5133 into apache:main Sep 4, 2026
14 checks passed
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