Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NamedTuple{...,Union{...}} values are serializable but inaccessible once deserialized #76

Closed
jrevels opened this issue Nov 29, 2020 · 0 comments · Fixed by #77
Closed

Comments

@jrevels
Copy link
Contributor

jrevels commented Nov 29, 2020

similarly flavored problem to #75:

julia> write_table(tbl) = (io = IOBuffer(); Arrow.write(io, tbl); seekstart(io); Arrow.Table(io))
write_table (generic function with 1 method)

julia> struct Foo
           a::Union{Int,String}
       end

julia> tbl = write_table((foos=[Foo(1), Foo("x")],))
Arrow.Table: (foos = Foo[Foo(1), Foo("x")],)

julia> tbl.foos[1] # works fine
Foo(1)

julia> const FooEmulation = NamedTuple{(:a,),Tuple{Union{Int,String}}}
NamedTuple{(:a,),Tuple{Union{Int64, String}}}

julia> tbl2 = write_table((foos=FooEmulation[(a=1,),(a="x",)],));

julia> tbl2.foos[1] # uh oh
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}}
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:171
Stacktrace:
 [1] convert(::Type{Tuple{Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}}}}, ::Tuple{Int64}) at ./essentials.jl:310
 [2] Tuple{Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}}}(::Tuple{Int64}) at ./tuple.jl:225
 [3] NamedTuple{(:a,),Tuple{Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}}}}(::Tuple{Int64}) at ./namedtuple.jl:90
 [4] getindex(::Arrow.Struct{NamedTuple{(:a,),Tuple{Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}}}},Tuple{Arrow.DenseUnion{Arrow.UnionT{Arrow.Flatbuf.UnionModeModule.Dense,nothing,Tuple{Union{Missing, Int64},String}},Tuple{Arrow.Primitive{Union{Missing, Int64},Array{Int64,1}},Arrow.List{String,Int32,Array{UInt8,1}}}}}}, ::Int64) at /Users/jarrettrevels/.julia/dev/Arrow/src/arraytypes/struct.jl:38
 [5] top-level scope at REPL[65]:1
quinnj added a commit that referenced this issue Dec 2, 2020
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.
@quinnj quinnj closed this as completed in #77 Dec 2, 2020
quinnj added a commit that referenced this issue Dec 2, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant