Skip to content

[SPARK-58408][CORE] Register TimestampNanosVal in KryoSerializer - #57607

Closed
viirya wants to merge 1 commit into
apache:masterfrom
viirya:kryo-register-timestamp-nanos
Closed

[SPARK-58408][CORE] Register TimestampNanosVal in KryoSerializer#57607
viirya wants to merge 1 commit into
apache:masterfrom
viirya:kryo-register-timestamp-nanos

Conversation

@viirya

@viirya viirya commented Jul 28, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Register org.apache.spark.unsafe.types.TimestampNanosVal in KryoSerializer, next to UTF8String which reached the registration list the same way (SPARK-51790).

Why are the changes needed?

Since SPARK-57735, cached-batch statistics rows carry TimestampNanosVal min/max bounds for nanosecond-timestamp columns -- TimestampNanosColumnStats in the default cache serializer, and the Arrow cache serializer's vector-side statistics (SPARK-57268). The statistics InternalRow is a field of DefaultCachedBatch / ArrowCachedBatch, so it is serialized with the batch whenever the cache uses a serialized storage level.

With spark.serializer=KryoSerializer and spark.kryo.registrationRequired=true, materializing such a cache fails at the first block write:

com.esotericsoftware.kryo.KryoException: java.lang.IllegalArgumentException:
Class is not registered: org.apache.spark.unsafe.types.TimestampNanosVal

This is the same defect class as SPARK-51777 (CachedBatch classes) and SPARK-51790 (UTF8String): a new class reachable from the cached-batch object graph was introduced without a matching Kryo registration. Every other bound type in statistics rows (UTF8String, Decimal, primitives) is already registered; TimestampNanosVal was the only gap -- the remaining stats collectors for non-orderable types (Variant, CalendarInterval, Geometry) record only sizes, no value objects.

Users with the default registrationRequired=false are unaffected (Kryo falls back to writing the class name). Nanosecond timestamp types are an unreleased 4.3.0 preview feature.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New test in CacheTableInKryoSuite (the suite from SPARK-51777/51790, which runs with registrationRequired=true): persists a TIMESTAMP_NTZ(9) column with DISK_ONLY. It fails without the registration with the exception above and passes with it. CacheTableInKryoSuite (4 tests) and core's *KryoSerializer* suites (81 tests) pass.

Was this patch authored or co-authored using generative AI tooling?

Yes, this pull request and its description were written by Claude Code.

Since SPARK-57735, cached-batch statistics rows carry TimestampNanosVal
min/max bounds for nanosecond-timestamp columns (TimestampNanosColumnStats
in the default cache serializer, and the Arrow cache serializer's
vector-side statistics). Persisting such a cache with a serialized storage
level under spark.serializer=KryoSerializer and
spark.kryo.registrationRequired=true failed at cache materialization with
"Class is not registered: org.apache.spark.unsafe.types.TimestampNanosVal",
because the class was never added to the registration list. Register it
next to UTF8String, which reached the list the same way (SPARK-51790).

Co-authored-by: Claude Code

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM.

@viirya viirya closed this in 177ce56 Jul 28, 2026
viirya added a commit that referenced this pull request Jul 28, 2026
### What changes were proposed in this pull request?

Register `org.apache.spark.unsafe.types.TimestampNanosVal` in `KryoSerializer`, next to `UTF8String` which reached the registration list the same way (SPARK-51790).

### Why are the changes needed?

Since SPARK-57735, cached-batch statistics rows carry `TimestampNanosVal` min/max bounds for nanosecond-timestamp columns -- `TimestampNanosColumnStats` in the default cache serializer, and the Arrow cache serializer's vector-side statistics (SPARK-57268). The statistics `InternalRow` is a field of `DefaultCachedBatch` / `ArrowCachedBatch`, so it is serialized with the batch whenever the cache uses a serialized storage level.

With `spark.serializer=KryoSerializer` and `spark.kryo.registrationRequired=true`, materializing such a cache fails at the first block write:

```
com.esotericsoftware.kryo.KryoException: java.lang.IllegalArgumentException:
Class is not registered: org.apache.spark.unsafe.types.TimestampNanosVal
```

This is the same defect class as SPARK-51777 (`CachedBatch` classes) and SPARK-51790 (`UTF8String`): a new class reachable from the cached-batch object graph was introduced without a matching Kryo registration. Every other bound type in statistics rows (`UTF8String`, `Decimal`, primitives) is already registered; `TimestampNanosVal` was the only gap -- the remaining stats collectors for non-orderable types (Variant, CalendarInterval, Geometry) record only sizes, no value objects.

Users with the default `registrationRequired=false` are unaffected (Kryo falls back to writing the class name). Nanosecond timestamp types are an unreleased 4.3.0 preview feature.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

New test in `CacheTableInKryoSuite` (the suite from SPARK-51777/51790, which runs with `registrationRequired=true`): persists a `TIMESTAMP_NTZ(9)` column with `DISK_ONLY`. It fails without the registration with the exception above and passes with it. `CacheTableInKryoSuite` (4 tests) and `core`'s `*KryoSerializer*` suites (81 tests) pass.

### Was this patch authored or co-authored using generative AI tooling?

Yes, this pull request and its description were written by Claude Code.

Closes #57607 from viirya/kryo-register-timestamp-nanos.

Authored-by: Liang-Chi Hsieh <viirya@gmail.com>
Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com>
(cherry picked from commit 177ce56)
Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com>
@viirya

viirya commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

@viirya
viirya deleted the kryo-register-timestamp-nanos branch July 28, 2026 23:17
@viirya

viirya commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Thanks @dongjoon-hyun

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