Repository navigation
Conversation
This branch has not been deployed
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.
Part of #4078 (the "Avro
timestamp-nanosraises Unknown logical type" item).Rationale for this change
AvroSchemaConversion.iceberg_to_avroalready writestimestamp_ns/timestamptz_nsas{"type": "long", "logicalType": "timestamp-nanos", "adjust-to-utc": ...}, butavro_to_iceberghas no branch fortimestamp-nanos. So an Avro file PyIceberg writes with a nanosecond timestamp field can't be opened byAvroFile, because it converts the schema from the file header first:This change maps
timestamp-nanostoTimestampNanoType, or toTimestamptzNanoTypewhenadjust-to-utcis true, the same waytimestamp-microsis handled. The readers and writers for these types already exist inpyiceberg/avro, so only the schema conversion was missing. I also fixed the parameter type hints on the twovisit_timestamp*_nsmethods, which saidTimestampType/TimestamptzType.Are these changes tested?
Yes:
tests/utils/test_schema_conversion.py:timestamp-nanoswithadjust-to-utcmissing, false, and true, plus an Iceberg -> Avro -> Iceberg schema round trip.tests/avro/test_file.py: writes a file withtimestamp_nsand optionaltimestamptz_nsfields usingAvroOutputFileand reads it back withAvroFile.All 5 new tests fail on
mainand pass with this change.pytest tests/avro tests/utils/test_schema_conversion.pypasses (193 tests), and ruff check/format are clean.Are there any user-facing changes?
Avro files with
timestamp-nanosfields can now be read. No API changes.AI disclosure: I used an AI coding assistant to help write this change and its tests. I reviewed the code and ran the tests myself.