Repository navigation
feat(avro): support local-timestamp logical types - #832
Merged
Merged
Conversation
Map the Avro local-timestamp-millis and local-timestamp-micros logical types to zone-less arrow.TimestampType values. These are now supported by hamba/avro, so the prior "not implemented in hamba/avro" note was stale. local-timestamp carries wall-clock (zone-less) semantics, distinct from the global timestamp-millis/micros types which map to a UTC-zoned arrow.TimestampType. hamba decodes a local-timestamp into a time.Time whose wall-clock fields are correct but whose location is the reader's machine zone; arrow.TimestampFromTime derives the stored value from the instant, so the machine offset would leak in. Reinterpret the wall-clock fields in UTC before conversion to keep the stored value zone-independent. Extend the all-types roundtrip and schema tests to cover both new types.
zeroshade
approved these changes
Jun 1, 2026
Member
|
LGTM! Thanks for this, I'll merge once the CI completes if all is green |
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.
Rationale for this change
arrow/avro/schema.gohad the Avrolocal-timestamp-millisandlocal-timestamp-microslogical types commented out with a note that they were "not implemented in hamba/avro". As of thegithub.com/hamba/avro/v2version this module depends on, both types are fully supported (defined as logical types, parsed, and encoded/decoded totime.Time), so the note is stale and the types can now be mapped.What changes are included in this PR
local-timestamp-millis/local-timestamp-microsto a zone-lessarrow.TimestampType(Millisecond/Microsecondunit, emptyTimeZone), reflecting their wall-clock semantics — as opposed to the globaltimestamp-millis/timestamp-microstypes which map to UTC-zoned types.reader_types.go: hamba decodes alocal-timestampinto atime.Timewhose wall-clock fields are correct but whose location is the reader's machine zone. Becausearrow.TimestampFromTimederives the stored value from the instant (Unix()), the machine's zone offset would otherwise leak into the stored value. The wall-clock fields are reinterpreted in UTC before conversion so the stored value is zone-independent.schema_test.go,reader_test.go,testdata/) to cover both new types. The roundtrip test was verified to fail without the conversion fix under a non-UTC timezone (e.g.TZ=Asia/Kolkata) and pass with it.Are these changes tested?
Yes —
go test ./arrow/avro/...passes, including under non-UTC timezones.Are there any user-facing changes?
Yes. Avro schemas using
local-timestamp-millis/local-timestamp-microswere previously unsupported; they now convert to zone-lessarrow.TimestampTypecolumns.