Skip to content
Permalink
Browse files
Fix Union type deserialization (#77)
* Fix Union type deserialization

Fixes #76. I think this was just a relic of old code from early work on
the package, but `juliaeltype` is meant to return "julia" types, not
arrow types.

* remove unintended change
  • Loading branch information
quinnj committed Dec 2, 2020
1 parent 32560d3 commit 92aea4654b9863b3036daf1e4bc77ed08c4d5f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
@@ -392,7 +392,7 @@ end

# Unions
function juliaeltype(f::Meta.Field, u::Meta.Union, convert)
return UnionT{u.mode, u.typeIds !== nothing ? Tuple(u.typeIds) : u.typeIds, Tuple{(juliaeltype(x, buildmetadata(x), convert) for x in f.children)...}}
return Union{(juliaeltype(x, buildmetadata(x), convert) for x in f.children)...}
end

arrowtype(b, x::Union{DenseUnion{TT, S}, SparseUnion{TT, S}}) where {TT, S} = arrowtype(b, TT, x)
@@ -184,6 +184,15 @@ tt = Arrow.Table(io)
@test length(tt) == length(t)
@test all(isequal.(values(t), values(tt)))

# 76
t = (col1=NamedTuple{(:a,),Tuple{Union{Int,String}}}[(a=1,), (a="x",)],)
io = IOBuffer()
Arrow.write(io, t)
seekstart(io)
tt = Arrow.Table(io)
@test length(tt) == length(t)
@test all(isequal.(values(t), values(tt)))

end # @testset "misc"

end

0 comments on commit 92aea46

Please sign in to comment.