Skip to content

ORC-2212: Fix AvroReader to handle java.time.Instant timestamps#2698

Closed
dongjoon-hyun wants to merge 1 commit into
apache:mainfrom
dongjoon-hyun:ORC-2212
Closed

ORC-2212: Fix AvroReader to handle java.time.Instant timestamps#2698
dongjoon-hyun wants to merge 1 commit into
apache:mainfrom
dongjoon-hyun:ORC-2212

Conversation

@dongjoon-hyun

Copy link
Copy Markdown
Member

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

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>
@dongjoon-hyun dongjoon-hyun added this to the 3.0.0 milestone Jul 17, 2026
@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Merged to main

@dongjoon-hyun
dongjoon-hyun deleted the ORC-2212 branch July 17, 2026 20:04
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.

1 participant