This is an automated email from the ASF dual-hosted git repository.

quinnj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git


The following commit(s) were added to refs/heads/main by this push:
     new 9b4de2b  add missing arrowtype(b, ::Type{<:Period}) method to enable 
roundtripping of Period types (#306)
9b4de2b is described below

commit 9b4de2b8fa8c24bcc3a85aecaa7eede1ebfa26f3
Author: Jarrett Revels <[email protected]>
AuthorDate: Fri Mar 18 17:54:26 2022 -0400

    add missing arrowtype(b, ::Type{<:Period}) method to enable roundtripping 
of Period types (#306)
---
 src/eltypes.jl   |  2 ++
 test/runtests.jl | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/eltypes.jl b/src/eltypes.jl
index b201aba..66f7a68 100644
--- a/src/eltypes.jl
+++ b/src/eltypes.jl
@@ -359,6 +359,8 @@ function arrowtype(b, ::Type{Duration{U}}) where {U}
     return Meta.Duration, Meta.durationEnd(b), nothing
 end
 
+arrowtype(b, ::Type{P}) where {P <: Dates.Period} = arrowtype(b, 
Duration{arrowperiodtype(P)})
+
 arrowperiodtype(P) = Meta.TimeUnits.SECOND
 arrowperiodtype(::Type{Dates.Millisecond}) = Meta.TimeUnits.MILLISECOND
 arrowperiodtype(::Type{Dates.Microsecond}) = Meta.TimeUnits.MICROSECOND
diff --git a/test/runtests.jl b/test/runtests.jl
index 5ed0e4d..a59156c 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -490,6 +490,7 @@ t2 = (
 # https://github.com/apache/arrow-julia/issues/253
 @test Arrow.toidict(Pair{String, String}[]) == Base.ImmutableDict{String, 
String}()
 
+# https://github.com/apache/arrow-julia/issues/232
 t = (; x=[Dict(true => 1.32, 1.2 => 0.53495216)])
 @test_throws ArgumentError("`keytype(d)` must be concrete to serialize 
map-like `d`, but `keytype(d) == Real`") Arrow.tobuffer(t)
 t = (; x=[Dict(32.0 => true, 1.2 => 0.53495216)])
@@ -497,6 +498,17 @@ t = (; x=[Dict(32.0 => true, 1.2 => 0.53495216)])
 t = (; x=[Dict(true => 1.32, 1.2 => true)])
 @test_throws ArgumentError("`keytype(d)` must be concrete to serialize 
map-like `d`, but `keytype(d) == Real`") Arrow.tobuffer(t)
 
+# https://github.com/apache/arrow-julia/issues/214
+t1 = (; x = [(Nanosecond(42),)])
+t2 = Arrow.Table(Arrow.tobuffer(t1))
+t3 = Arrow.Table(Arrow.tobuffer(t2))
+@test t3.x == t1.x
+
+t1 = (; x = [(; a=Nanosecond(i), b=Nanosecond(i+1)) for i = 1:5])
+t2 = Arrow.Table(Arrow.tobuffer(t1))
+t3 = Arrow.Table(Arrow.tobuffer(t2))
+@test t3.x == t1.x
+
 end # @testset "misc"
 
 end

Reply via email to