Adds Arrow Duration type support to arrow-avro reader and writer #8393
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.
Which issue does this PR close?
Rationale for this change
This change adds support for Arrow DataType::Duration to the arrow-avro crate. Previous versions of this code return a NotYetImplemented error encouraging users to manually cast to Interval(MonthDayNano). With this change, Duration will now be represented as a long, with a metadata value of
arrowDurationType
which corresponds to the TimeUnit. This retains the Arrow paradigm for Duration of clock time, rather than the Avro approach of calendar time. Because of this disconnect between the two specs, any attempt to map the value (e.g. seconds into days) would be lossy, as days and months can be of varying length.What changes are included in this PR?
Expands the arrow-avro crate to handle Arrow
Duration
types with variousTimeUnit
variants (Second, Millisecond, Microsecond, Nanosecond). Includes:Duration
types.Are these changes tested?
Yes, existing tests are all passing, and tests have been added to validate the encoding and decoding of Duration.
Are there any user-facing changes?