The code below contains two examples: the first example works, the second one doesn’t. The first example creates a struct, then writes it to an arrow file (which converts it to a named tuple along the way). Reading it back works fine.
In the second example, there is a vector of structures structure nested inside the outside structure. This does not work, because the inside argument is still a tuple, not a structure. What would be the best way of getting this to work? Write new constructors? Thanks!
using Arrow, DataFrames
struct Mine
x::Int
y::Vector{Int}
z::String
end
m1 = Mine( 0, [1;2], "one" )
m2 = Mine( 1, [4;6], "two" )
df = DataFrame( m = [m1;m2] )
Arrow.write( "mine.arrow", df )
df2 = Arrow.Table( "mine.arrow" ) |> DataFrame
println( typeof( df2[1,:m] ) )
println( Mine( df2[1,:m]... ) )
# the above works
struct Another
a::String
b::Vector{Mine}
end
m3 = Mine( 0, [1;2;8], "three" )
a1 = Another( "first", [m1;m2] )
a2 = Another( "second", [m2;m3] )
dfa = DataFrame( a = [a1; a2] )
Arrow.write( "another.arrow", dfa)
dfa2 = Arrow.Table( "another.arrow" ) |> DataFrame
println( dfa2[1,:a] )
# how best to do what is intended below?
println( Another( dfa2[1,:a]... ) )