ORC-2212: Fix AvroReader to handle java.time.Instant timestamps#2698
Closed
dongjoon-hyun wants to merge 1 commit into
Closed
ORC-2212: Fix AvroReader to handle java.time.Instant timestamps#2698dongjoon-hyun wants to merge 1 commit into
dongjoon-hyun wants to merge 1 commit into
Conversation
dongjoon-hyun
added a commit
that referenced
this pull request
Jul 17, 2026
### What changes were proposed in this pull request?
This PR aims to fix `AvroReader.TimestampConverter` to handle `java.time.Instant` values produced by Avro 1.12.1.
- The converter now accepts both `java.time.Instant` (Avro 1.12.1+) and `Long` (older behavior), extracting epoch milliseconds via `Instant.toEpochMilli()` while preserving the existing `nanos = 0` behavior.
### Why are the changes needed?
Starting from Avro 1.12.1, decoding the `timestamp-millis` logical type returns a `java.time.Instant` instead of a raw `Long`. The existing converter cast the value directly to `Long`, causing a `ClassCastException` and breaking `java-bench-scan-test`:
```
java.lang.ClassCastException: class java.time.Instant cannot be cast to class java.lang.Long
at org.apache.orc.bench.core.convert.avro.AvroReader$TimestampConverter.convert(AvroReader.java:192)
at org.apache.orc.bench.core.convert.parquet.ParquetReader.nextBatch(ParquetReader.java:58)
at org.apache.orc.bench.core.convert.ScanVariants.run(ScanVariants.java:92)
at org.apache.orc.bench.core.Driver.main(Driver.java:64)
```
Since `timestamp-millis` has millisecond precision, an `Instant`'s sub-millisecond nanoseconds are always zero, so keeping `nanos = 0` preserves the previous observable behavior.
### How was this patch tested?
Pass the CIs, including the previously failing `java-bench-scan-test`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8
Closes #2698 from dongjoon-hyun/ORC-2212.
Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit a6f12fd)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Member
Author
|
Merged to main |
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?
This PR aims to fix
AvroReader.TimestampConverterto handlejava.time.Instantvalues produced by Avro 1.12.1.java.time.Instant(Avro 1.12.1+) andLong(older behavior), extracting epoch milliseconds viaInstant.toEpochMilli()while preserving the existingnanos = 0behavior.Why are the changes needed?
Starting from Avro 1.12.1, decoding the
timestamp-millislogical type returns ajava.time.Instantinstead of a rawLong. The existing converter cast the value directly toLong, causing aClassCastExceptionand breakingjava-bench-scan-test:Since
timestamp-millishas millisecond precision, anInstant's sub-millisecond nanoseconds are always zero, so keepingnanos = 0preserves the previous observable behavior.How was this patch tested?
Pass the CIs, including the previously failing
java-bench-scan-test.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8