JuliaData / Feather.jl

Read and write feather files in pure Julia
https://juliadata.github.io/Feather.jl/stable
Other
109 stars 27 forks source link

method ambiguity when writing columns with eltype `Union{DateTime, Missing}` #70

Closed ExpandingMan closed 6 years ago

ExpandingMan commented 6 years ago

See the following

using DataFrames
using Feather

df = DataFrame(A=Union{DateTime,Missing}[DateTime(), DateTime(), missing], B=rand(3), C=rand(Int64,3))

Feather.write("test1.feather", df)

gives

ERROR: LoadError: MethodError: Feather.writecolumn(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Type{DateTime}, ::Array{Union{DateTime, Missings.Missing},1}) is ambiguous. Candidates:
  writecolumn(io, ::Type{T}, A::Array{Union{Missings.Missing, T},1}) where T in Feather at /home/expandingman/.julia/v0.6/Feather/src/Feather.jl:352
  writecolumn(io, ::Type{DateTime}, A) in Feather at /home/expandingman/.julia/v0.6/Feather/src/Feather.jl:349
Possible fix, define
  writecolumn(::Any, ::Type{DateTime}, ::Array{Union{DateTime, Missings.Missing},1})
Stacktrace:
 [1] close!(::Feather.Sink{DataFrames.DataFrameStream{Tuple{Array{Union{DateTime, Missings.Missing},1},Array{Float64,1},Array{Int64,1}}}}) at /home/expandingman/.julia/v0.6/Feather/src/Feather.jl:470
 [2] #write#46(::Bool, ::Dict{Int64,Function}, ::Array{Any,1}, ::Function, ::String, ::DataFrames.DataFrame) at /home/expandingman/.julia/v0.6/Feather/src/Feather.jl:523
 [3] write(::String, ::DataFrames.DataFrame) at /home/expandingman/.julia/v0.6/Feather/src/Feather.jl:522
 [4] include_from_node1(::String) at ./loading.jl:576
 [5] include(::String) at ./sysimg.jl:14
while loading /home/expandingman/src/scrap.jl, in expression starting on line 6

Investigating fixes...

jacobadenbaum commented 6 years ago

I am still having this problem when using Feather on a dataframe with columns of dates or of Bools. See the adapted version of the above example (which also fails for me) using the most recent version of Feather.jl and DataFrames.jl:

using DataFrames
using Feather

df = DataFrame(A=Union{Bool,Missing}[true, false, missing], 
               B=rand(3),
               C=rand(Int64,3))

Feather.write("test1.feather", df)

gives

ERROR: LoadError: MethodError:
Feather.writecolumn(::Base.AbstractIOBuffer{Array{UInt8,1}},
::Type{Bool}, ::Array{Union{Bool, Missings.Missing},1}) is ambiguous.
Candidates:
    writecolumn(io, ::Type{T}, A::Array{Union{Missings.Missing, T},1})
        where T in Feather at
        /Users/jacob/.julia/v0.6/Feather/src/Feather.jl:352
    writecolumn(io, ::Type{Bool}, A) in Feather at
        /Users/jacob/.julia/v0.6/Feather/src/Feather.jl:334
Possible fix, define
writecolumn(::Any, ::Type{Bool}, ::Array{Union{Bool, Missings.Missing},1})
Stacktrace:
[1] close!(::Feather.Sink{DataFrames.DataFrameStream{Tuple{Array{Union{Bool,
    Missings.Missing},1},Array{Float64,1},Array{Int64,1}}}}) at
    /Users/jacob/.julia/v0.6/Feather/src/Feather.jl:470
[2] #write#46(::Bool, ::Dict{Int64,Function}, ::Array{Any,1},
    ::Function, ::String, ::DataFrames.DataFrame) at
    /Users/jacob/.julia/v0.6/Feather/src/Feather.jl:523
[3] write(::String, ::DataFrames.DataFrame) at
    /Users/jacob/.julia/v0.6/Feather/src/Feather.jl:522
[4] include_from_node1(::String) at ./loading.jl:576
[5] include(::String) at ./sysimg.jl:14