Skip to content

Commit

Permalink
Fix datavaluetype function (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff authored and quinnj committed Oct 2, 2018
1 parent 763c900 commit c473cf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/datavalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ nondatavaluetype(::Type{DataValue{T}}) where {T} = Union{T, Missing}
unwrap(x::DataValue) = isna(x) ? missing : DataValues.unsafe_get(x)
datavaluetype(::Type{T}) where {T <: DataValue} = T
datavaluetype(::Type{Union{T, Missing}}) where {T} = DataValue{T}
datavaluetype(::Type{Missing}) = DataValue{Union{}}

struct DataValueRowIterator{NT, S}
x::S
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,8 @@ end
mt = Tables.DataValueUnwrapper(ei.x |> y->QueryOperators.map(y, x->(a=x.a, c=x.c), Expr(:block)))
@test (mt |> columntable) == (a = Real[1, 2.0, 3], c = ["7", "8", "9"])
@test length(mt |> rowtable) == 3

rt = (a = Missing[missing, missing], b=[1,2])
dv = Tables.datavaluerows(rt)
@test eltype(dv) == NamedTuple{(:a, :b), Tuple{DataValue{Union{}}, Int}}
end

0 comments on commit c473cf7

Please sign in to comment.