The code from BKadmin indeed works, but as mentioned is not applicable to my use case.
Looking a bit closer at what is happening, I get the following output from the open command
julia> writer = open(Arrow.Writer, filename, metadata=meta, colmetadata = Dict(:Column1 => metacol1, :Column2 => metacol2))
Arrow.Writer{IOStream}(IOStream(<file test.arrow>), true, nothing, true, false, true, false, false, true, 8, 6, Base.ImmutableDict("why" => "gain experience", "when" => "now", "file" => "test.arrow"), Base.ImmutableDict(:Column1 => Base.ImmutableDict("comment" => "Col 1 comment", "id" => "col1"), :Column2 => Base.ImmutableDict("comment" => "Col 2 comment", "id" => "col2")), ConcurrentUtilities.OrderedSynchronizer(Task (runnable) @0x0000025285e45370, Base.GenericCondition{ReentrantLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (8, 2554407032536, 2553475134096))), 2, false), Channel{Arrow.Message}(2147483647), Base.RefValue{Tables.Schema}(#undef), Base.RefValue{Any}(#undef), Dict{Int64, Any}(), (Arrow.Block[], Arrow.Block[]), Task (runnable) @0x0000025285b91560, Base.Threads.Atomic{Bool}(false), Base.RefValue{Any}(#undef), 1, false)
If you review the output the metadata and colmetadata Dictionaries are both present .
Then I do a couple of writes and find the metadata and colmetadata are still present
for i in 1:2
result = rand(2, 2) .+ i
Arrow.write(writer, Tables.table(result)) #, header=[:a,:b])
end
julia> writer
Arrow.Writer{IOStream}(IOStream(<file test.arrow>), true, nothing, true, false, true, false, false, true, 8, 6, Base.ImmutableDict("why" => "gain experience", "when" => "now", "file" => "test.arrow"), Base.ImmutableDict(:Column1 => Base.ImmutableDict("comment" => "Col 1 comment", "id" => "col1"), :Column2 => Base.ImmutableDict("comment" => "Col 2 comment", "id" => "col2")), ConcurrentUtilities.OrderedSynchronizer(Task (runnable) @0x0000025285e45370, Base.GenericCondition{ReentrantLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (8, 2554407032536, 2553475134096))), 3, false), Channel{Arrow.Message}(2147483647), Base.RefValue{Tables.Schema}(Tables.Schema:
:Column1 Float64
:Column2 Float64), Base.RefValue{Any}(Arrow.ToArrowTable(Tables.Schema:
:Column1 Float64
:Column2 Float64, Any[[1.6538333373705436, 1.1112311527966914], [1.5588581037092983, 1.230890307877189]], Base.ImmutableDict("file" => "test.arrow", "when" => "now", "why" => "gain experience"), Arrow.DictEncoding[])), Dict{Int64, Any}(), (Arrow.Block[Arrow.Block(520, 192, 32), Arrow.Block(744, 192, 32)], Arrow.Block[]), Task (runnable) @0x0000025285b91560, Base.Threads.Atomic{Bool}(false), Base.RefValue{Any}(#undef), 3, false)
Then I close the writer and and read the table and find the metadata is read, but the colmetadata shows as “nothing”.
julia> close(writer)
julia> tbl = Arrow.Table(filename)
Arrow.Table with 4 rows, 2 columns, and schema:
:Column1 Float64
:Column2 Float64
with metadata given by a Base.ImmutableDict{String, String} with 3 entries:
"why" => "gain experience"
"when" => "now"
"file" => "test.arrow"
julia> Arrow.getmetadata(tbl)
Base.ImmutableDict{String, String} with 3 entries:
"why" => "gain experience"
"when" => "now"
"file" => "test.arrow"
julia> Arrow.getmetadata(tbl.Column1) === nothing
true
julia> Arrow.getmetadata(tbl.Column2) === nothing
true
So in Summary it seems like a reading problem rather than a writing problem. Perhaps it is solved in the PR 481?
Is there a timeline to merge the suggested PR?