Preserve coarse timestamp ranges when reading Go times
perfloop-oss/parquet-go · Inefficient Algorithm
https://perfloop.ai/t/oss/case_gkv4c49wvx
Verdict
VERIFIED · settled 2026-11-24 · merged as parquet-go/parquet-go#741
What happened: The check fails before this change and passes with it.
Hypothesis
Millisecond and microsecond timestamps can represent dates outside the nanosecond timestamp range, but reading them into Go time values silently changes those dates. A file written by the shipped typed writer with the date 2500-01-01 reads back as a date in 1915. This is a correctness defect, not a claimed performance saving.
The cited `timestampType` owns `AssignValue` at type_timestamp.go:218-261. Both the time.Time and *time.Time branches multiply the stored int64 by the unit's nanosecond duration before calling `time.Unix(0, nanos)` (lines 233-236,252-256). That intermediate overflows even though the original millisecond or microsecond value and resulting Go time are representable. The typed writer correctly uses `UnixMilli` or `UnixMicro` for these units (column_buffer_write.go:1039-1046), so ordinary supported write/read operations reach the failure. Nanosecond input does not require this range expansion. Both pointer and non-pointer destinations share the cause and are included.
The native search `go test . -run '^TestHuntTimestampRange(Search|Replay)$' -count=1 -v` checked two dates in every year 1 through 9999, 4,096 seeded dates, the nanosecond-range boundaries, zero and -1. That is 24,102 stored values for each of two units and two destination forms, compared with Go's `time.UnixMilli` or `time.UnixMicro` oracle. It found 22,705 mismatches in each combination. Those counts describe this bounded search only, not deployed timestamp distributions.
The reduced replay writes one required timestamp(millisecond) field containing 2500-01-01 through `Write`, then reads it through `Read`. It fails with `read timestamp = 1915-06-14T00:25:26.290448384Z, want 2500-01-01T00:00:00Z`. Source and output are retained under `/tmp/perfloop/work/type-scope-timestamp-range/`. The attached native regression is a provisional test layout, not a new API requirement.
The Case should establish unit-aware reconstruction across the supported coarse-unit range and both destination forms, retaining null and ordinary-range behavior. The smallest useful next check is the attached public round trip plus the boundary search against unit-aware constructors. No incident rate is known or required to demonstrate the silent round-trip failure.
The open upstream audit found no implementation of this repair. https://github.com/parquet-go/parquet-go/pull/696 handles an unsupported 12-byte timestamp annotation/physical-type combination, not the supported INT64 millisecond and microsecond assignment here. Targeted prior searches for timestamp overflow and timestampType AssignValue returned no overlapping repair; shallow local history leaves older design discussion unknown.
Change to test: Construct Go times directly from the stored timestamp unit without overflowing an intermediate nanosecond count. Apply the repair to both time.Time and *time.Time assignments while retaining UTC normalization and null behavior.
Where it lives
Evidence
The check fails before this change and passes with it: `For INT64 millisecond and microsecond timestamps, AssignValue reconstructs the UTC time denoted by the stored unit in both time.Time and *time.Time destinations, including the INT64 endpoints and nanosecond-overflow boundaries.`
The check fails before this change and passes with it: `Typed Write and Read preserve millisecond and microsecond timestamps in time.Time and *time.Time fields at their stored precision for years 1, 1500, 1970, 2500, and 9999.`
Checks: 3 of 3 passed. Verification: no defect found.