Skip to content

feat: reduce allocations in Spark Decimal access - #9842

Open
xiaoh1024 wants to merge 1 commit into
vortex-data:developfrom
xiaoh1024:exp/decimal-accessor-pr
Open

feat: reduce allocations in Spark Decimal access#9842
xiaoh1024 wants to merge 1 commit into
vortex-data:developfrom
xiaoh1024:exp/decimal-accessor-pr

Conversation

@xiaoh1024

Copy link
Copy Markdown

Summary

Closes #9837. See the issue for the motivation, design, benchmark results, and decimal-specific validation.

Changes

  • Add SmallDecimalAccessor for source precision 1–18, preserving full-width fallback and Spark's decimal conversion semantics.
  • Add regression tests for decimal decoding, conversions, and returned-value independence.

AI assistance: AI assistance was used for implementation, tests, validation tooling, and this description, including translation from Chinese.

Read small-precision Decimal128 values from native long words, retaining
the full-width Arrow conversion when the integer cannot fit in a long.
Handle both native word orders and use the source scale when constructing
BigDecimal, leaving requested rescaling and overflow checks to Spark.
Preserve Spark's expanded Decimal representation for checked integer casts.

Add tests for decimal values, rescaling, malformed buffers, both word
orders, slices, object independence, negative scales and checked casts.

Validated on Spark 3.5.9/Scala 2.12 and Spark 4.1.2/Scala 2.13, with 26
targeted tests per version plus Javadoc and test formatting checks.
AI-assisted implementation and tests.

Signed-off-by: Peifeng Li <lipeifeng@xiaohongshu.com>
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.

Reduce allocations when reading small-precision decimals in the Spark connector

1 participant