Repository navigation
fix(avro): decode nullable logical timestamps - #935
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
Fix looks correct, and the union-branch handling preserves UTC vs. local timestamp semantics nicely. Just an optional test-coverage suggestion, non-blocking.
| assert.True(t, nullable.IsNull(1)) | ||
| } | ||
|
|
||
| func TestOCFReaderNullableLocalTimestampMicros(t *testing.T) { |
There was a problem hiding this comment.
Optional: this end-to-end OCF test only exercises local-timestamp-micros. TestAppendTimestampDataUnionBranches covers all four branch names at the appender level, but OCF-level coverage for nullable global timestamp-millis/timestamp-micros and local-timestamp-millis would also catch any integration mismatch in Hamba's branch naming/decoding for those flavors.
There was a problem hiding this comment.
Addressed in c70bea6. TestOCFReaderNullableTimestamps now exercises timestamp-millis, timestamp-micros, local-timestamp-millis, and local-timestamp-micros end to end through OCF, with one non-null and one null record per type. Verified under TZ=UTC and TZ=Asia/Jerusalem. Thanks!
zeroshade
left a comment
There was a problem hiding this comment.
LGTM — verified the fix and its test coverage. Thanks!
Port TestOCFReaderNullableTimestamps from upstream apache#935, which the hamba->twmb migration displaced. Extends it with the nanos variants and pins time.Local to a non-UTC zone so a machine's TZ cannot shift the decoded value. The OCF writer is given the raw schema JSON via ocf.WithSchema: twmb defaults the header to the parsing canonical form, which by spec strips logical types and would make the fixture meaningless. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Rationale for this change
This is a follow-up to #832, which added support for Avro local timestamp logical types.
For nullable timestamp fields, Hamba decodes a selected logical union branch as a one-entry map such as
"long.local-timestamp-micros": time.Time.appendTimestampDataonly inspected the plain"long"branch, so it treated valid non-null logical timestamp values as null.What changes are included in this PR?
timestamp-millis,timestamp-micros,local-timestamp-millis, andlocal-timestamp-micros, while preserving plainlongunions.time.Timeunion values through the existing timestamp conversion, including UTC wall-clock reinterpretation for local timestamps.Are these changes tested?
Yes. The regression failed before the fix because non-null logical timestamp values were appended as null. The full Avro suite passes in UTC and a non-UTC timezone:
TZ=UTC go test ./arrow/avro/... -count=1TZ=Asia/Jerusalem go test ./arrow/avro/... -count=1golangci-lint v2.11.3 run --timeout=5m ./arrow/avro/...Are there any user-facing changes?
Yes. Non-null values in nullable Avro timestamp logical fields are now decoded as Arrow timestamps instead of null.