queryverse / IterableTables.jl

Implementations of the TableTraits.jl interface for various packages
Other
79 stars 9 forks source link

Sinking to TimeArray sensitive to Array element type #53

Open Keno opened 7 years ago

Keno commented 7 years ago

In code like:

ts3 = @from i in df3 begin
    @select {i.timestamp, i.NMerged}
    @collect TimeArray
end

I get

MethodError: no method matching TimeSeries.TimeArray(::Array{Any,1}, ::Array{Int64,2}, ::Array{String,1})
Closest candidates are:
  TimeSeries.TimeArray(::AbstractArray{D<:Base.Dates.TimeType,1}, ::AbstractArray{T,N}, ::Array{S<:AbstractString,1}, ::Any) where {T, N, D<:Base.Dates.TimeType, S<:AbstractString} at /home/juser/.julia/v0.6/TimeSeries/src/timearray.jl:41
  TimeSeries.TimeArray(::D<:Base.Dates.TimeType, ::AbstractArray{T,N}, ::Array{S<:AbstractString,1}, ::Any) where {T, N, D<:Base.Dates.TimeType, S<:AbstractString} at /home/juser/.julia/v0.6/TimeSeries/src/timearray.jl:44
  TimeSeries.TimeArray(::AbstractArray{D<:Base.Dates.TimeType,1}, ::AbstractArray, ::Any) where D<:Base.Dates.TimeType at /home/juser/.julia/v0.6/TimeSeries/src/timearray.jl:55
  ...

this is because timestamp has Any type, even though all the elements are DateTime. Inserting a df3[:timestamp] = map(identity, df3[:timestamp]) fixes the element type of the column and the error goes away, but I'd like IterableTables to do so by itself (and give a nice error if the timestamp is not of time type).