Skip to content
Permalink
Browse files
convert Arrow-flavored eltypes to Julia-flavored eltypes on copy (#98)
* convert Arrow-flavored eltypes to Julia-flavored eltypes on copy

* Update src/arraytypes/primitive.jl

Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
  • Loading branch information
jrevels and quinnj committed Jan 5, 2021
1 parent f92592c commit 1a5d6e415b1125c9d3b5d19c8baff18128953222
Showing 2 changed files with 12 additions and 2 deletions.
@@ -32,8 +32,8 @@ Primitive(::Type{T}, b::Vector{UInt8}, v::ValidityBitmap, data::A, l, meta) wher

Base.size(p::Primitive) = (p.ℓ,)

function Base.copy(p::Primitive)
if nullcount(p) == 0
function Base.copy(p::Primitive{T, A}) where {T, A}
if nullcount(p) == 0 && T === eltype(A)
return copy(p.data)
else
return convert(Array, p)
@@ -198,6 +198,16 @@ tt = Arrow.Table(io)
u = 0x6036fcbd20664bd8a65cdfa25434513f
@test Arrow.ArrowTypes.arrowconvert(UUID, (value=u,)) === UUID(u)

# 98
t = (a = [Nanosecond(0), Nanosecond(1)], b = [uuid4(), uuid4()], c = [missing, Nanosecond(1)])
io = IOBuffer()
Arrow.write(io, t)
seekstart(io)
tt = Arrow.Table(io)
@test copy(tt.a) isa Vector{Nanosecond}
@test copy(tt.b) isa Vector{UUID}
@test copy(tt.c) isa Vector{Union{Missing,Nanosecond}}

end # @testset "misc"

end

0 comments on commit 1a5d6e4

Please sign in to comment.