[SPARK-56411][SQL] Register Decimal in KryoSerializer so cached-batch spill works#55287
Closed
LuciferYang wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-56411][SQL] Register Decimal in KryoSerializer so cached-batch spill works#55287LuciferYang wants to merge 1 commit intoapache:masterfrom
LuciferYang wants to merge 1 commit intoapache:masterfrom
Conversation
… spill works Register `Decimal`, `Decimal[]`, `java.math.BigDecimal`, and `java.math.BigInteger` in `KryoSerializer.loadableSparkClasses` so that Kryo strict registration mode can serialize these types without throwing `Class is not registered`. `DefaultCachedBatchSerializer` writes cached batch stats via `kryo.writeClassAndObject(output, batch.stats)`. The stats row can contain `Decimal` values (e.g. min/max for a DecimalType column). None of these classes were registered, causing any cache spill or eviction under strict mode to crash with KryoException.
Member
|
Could you revise the PR title, @LuciferYang ? |
Contributor
Author
done |
dongjoon-hyun
approved these changes
Apr 10, 2026
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Thank you, @LuciferYang .
Contributor
Author
|
Thank you @dongjoon-hyun |
Contributor
Author
|
Merged into master. Thanks @dongjoon-hyun |
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.
What changes were proposed in this pull request?
Register
Decimal,Decimal[],java.math.BigDecimal, andjava.math.BigIntegerinKryoSerializer.loadableSparkClassesso that Kryo strict registration mode(spark.kryo.registrationRequired=true) can serialize these types without throwingClass is not registered.Why are the changes needed?
DefaultCachedBatchSerializerwrites cached batch stats viakryo.writeClassAndObject(output, batch.stats). The stats row (GenericInternalRow) can containDecimalvalues (e.g. min/max stats for aDecimalTypecolumn). When Kryo walks the row it encounters:org.apache.spark.sql.types.Decimal-- the value class itself.java.math.BigDecimal/java.math.BigInteger-- used internally when the value overflowsLongprecision (> 18 digits).None of these were registered. Under strict mode, any cache spill or eviction of a batch with Decimal stats crashes:
This can be reproduced by caching a table with
DecimalTypecolumns(e.g.CACHE TABLE store_sales) and triggering a memory-pressure spill under Kryo strict mode.Does this PR introduce any user-facing change?
No.
How was this patch tested?
DefaultCachedBatchKryoSerializerSuiteWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code