Skip to content
Permalink
Browse files
Support VersionNumber (#205)
Co-authored-by: Jarrett Revels <jarrettrevels@gmail.com>
  • Loading branch information
omus and jrevels committed May 31, 2021
1 parent 656c66e commit d3b32ea1d276ab95ecc971f070e1a491f74fd8e9
Showing 3 changed files with 27 additions and 1 deletion.
@@ -270,6 +270,16 @@ arrowname(::Type{Tuple{}}) = TUPLE
JuliaType(::Val{TUPLE}, ::Type{NamedTuple{names, types}}) where {names, types <: Tuple} = types
fromarrow(::Type{T}, x::NamedTuple) where {T <: Tuple} = Tuple(x)

# VersionNumber
const VERSION_NUMBER = Symbol("JuliaLang.VersionNumber")
ArrowKind(::Type{VersionNumber}) = StructKind()
arrowname(::Type{VersionNumber}) = VERSION_NUMBER
JuliaType(::Val{VERSION_NUMBER}) = VersionNumber

function fromarrow(::Type{VersionNumber}, v::NamedTuple)
VersionNumber(v.major, v.minor, v.patch, v.prerelease, v.build)
end

"MapKind data are stored similarly to ListKind, where elements are flattened, and a 2nd offsets buffer contains the individual list element length data"
struct MapKind <: ArrowKind end

@@ -98,6 +98,13 @@ nt = (id=1, name="bob")
@test ArrowTypes.JuliaType(Val(ArrowTypes.TUPLE), NamedTuple{(Symbol("1"), Symbol("2")), Tuple{Int, String}}) == Tuple{Int, String}
@test ArrowTypes.fromarrow(Tuple{Int, String}, nt) == (1, "bob")

v = v"1"
v_nt = (major=1, minor=0, patch=0, prerelease=(), build=())
@test ArrowTypes.ArrowKind(VersionNumber) == ArrowTypes.StructKind()
@test ArrowTypes.arrowname(VersionNumber) == ArrowTypes.VERSION_NUMBER
@test ArrowTypes.JuliaType(Val(ArrowTypes.VERSION_NUMBER)) == VersionNumber
@test ArrowTypes.fromarrow(typeof(v), v_nt) == v

@test ArrowTypes.ArrowKind(Dict{String, Int}) == ArrowTypes.MapKind()
@test ArrowTypes.ArrowKind(Union{String, Int}) == ArrowTypes.UnionKind()

@@ -119,4 +126,4 @@ nt = (id=1, name="bob")
@test ArrowTypes.ToArrow(Any[1, 3.14]) == [1.0, 3.14]
@test ArrowTypes.ToArrow(Any[1, 3.14, "hey"]) == [1.0, 3.14, "hey"]

end
end
@@ -341,6 +341,15 @@ t = (
tbl = Arrow.Table(Arrow.tobuffer(t))
@test eltype(tbl.col1) == Vector{String}

# 200
@testset "VersionNumber" begin
t = (
col1=[v"1"],
)
tbl = Arrow.Table(Arrow.tobuffer(t))
@test eltype(tbl.col1) == VersionNumber
end

end # @testset "misc"

end

0 comments on commit d3b32ea

Please sign in to comment.