Commit 447bf3e
authored
Adds Duration(TimeUnit) support to arrow-avro reader and writer (#8433)
# Which issue does this PR close?
- Part of #4886
# 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 logicalType
value corresponding to the TimeUnit of the Arrow duration
(`arrow.duration-nanos`, `arrow.duration-micros`,
`arrow.duration-millis`, `arrow.duration-seconds`). This retains the
Arrow paradigm for Duration of clock time, rather than the Avro approach
of [calendar
time](https://avro.apache.org/docs/1.11.1/specification/#duration).
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
various `TimeUnit` variants (Second, Millisecond, Microsecond,
Nanosecond). Includes:
- Additions in encoder/decoder to support Duration types.
- Updates to schema handling for duration-specific metadata.
- Comprehensive unit tests for reading and writing `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. A round trip test has
been added to `writer/mod.rs`.
# Are there any user-facing changes?
- Crate is not yet public1 parent fedef66 commit 447bf3e
File tree
10 files changed
+548
-16
lines changed- arrow-avro
- src
- reader
- writer
- test/data
10 files changed
+548
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| |||
685 | 690 | | |
686 | 691 | | |
687 | 692 | | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
688 | 705 | | |
689 | 706 | | |
690 | 707 | | |
| |||
759 | 776 | | |
760 | 777 | | |
761 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
762 | 787 | | |
763 | 788 | | |
764 | 789 | | |
| |||
944 | 969 | | |
945 | 970 | | |
946 | 971 | | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
947 | 977 | | |
948 | 978 | | |
949 | 979 | | |
| |||
1317 | 1347 | | |
1318 | 1348 | | |
1319 | 1349 | | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1320 | 1360 | | |
1321 | 1361 | | |
1322 | 1362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
211 | 218 | | |
212 | 219 | | |
213 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1303 | 1303 | | |
1304 | 1304 | | |
1305 | 1305 | | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1306 | 1310 | | |
1307 | 1311 | | |
1308 | 1312 | | |
1309 | 1313 | | |
1310 | 1314 | | |
1311 | 1315 | | |
1312 | | - | |
| 1316 | + | |
| 1317 | + | |
1313 | 1318 | | |
1314 | 1319 | | |
1315 | 1320 | | |
| |||
4747 | 4752 | | |
4748 | 4753 | | |
4749 | 4754 | | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
| 4796 | + | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
| 4805 | + | |
| 4806 | + | |
| 4807 | + | |
| 4808 | + | |
| 4809 | + | |
| 4810 | + | |
| 4811 | + | |
| 4812 | + | |
| 4813 | + | |
| 4814 | + | |
| 4815 | + | |
| 4816 | + | |
| 4817 | + | |
| 4818 | + | |
| 4819 | + | |
| 4820 | + | |
| 4821 | + | |
| 4822 | + | |
| 4823 | + | |
| 4824 | + | |
| 4825 | + | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
| 4832 | + | |
| 4833 | + | |
| 4834 | + | |
| 4835 | + | |
| 4836 | + | |
| 4837 | + | |
| 4838 | + | |
| 4839 | + | |
| 4840 | + | |
| 4841 | + | |
| 4842 | + | |
| 4843 | + | |
| 4844 | + | |
| 4845 | + | |
| 4846 | + | |
| 4847 | + | |
| 4848 | + | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
| 4852 | + | |
| 4853 | + | |
| 4854 | + | |
| 4855 | + | |
| 4856 | + | |
4750 | 4857 | | |
4751 | 4858 | | |
4752 | 4859 | | |
| |||
0 commit comments