Skip to content
Permalink
Browse files
Handle empty tuple (#201)
  • Loading branch information
omus committed May 31, 2021
1 parent 48292d7 commit 656c66e4672530619c3fcaaf9e30b1dea2ffe694
Showing 3 changed files with 14 additions and 0 deletions.
@@ -261,10 +261,12 @@ fromarrow(::Type{NamedTuple{names, types}}, x::NamedTuple{names, types}) where {
fromarrow(::Type{T}, x::NamedTuple) where {T} = fromarrow(T, Tuple(x)...)

ArrowKind(::Type{<:Tuple}) = StructKind()
ArrowKind(::Type{Tuple{}}) = StructKind()
const TUPLE = Symbol("JuliaLang.Tuple")
# needed to disambiguate the FixedSizeList case for NTuple
arrowname(::Type{NTuple{N, T}}) where {N, T} = EMPTY_SYMBOL
arrowname(::Type{T}) where {T <: Tuple} = TUPLE
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)

@@ -92,7 +92,9 @@ nt = (id=1, name="bob")
@test ArrowTypes.fromarrow(typeof(nt), nt) === nt
@test ArrowTypes.fromarrow(Person, nt) == Person(1, "bob")
@test ArrowTypes.ArrowKind(Tuple) == ArrowTypes.StructKind()
@test ArrowTypes.ArrowKind(Tuple{}) == ArrowTypes.StructKind()
@test ArrowTypes.arrowname(Tuple{Int, String}) == ArrowTypes.TUPLE
@test ArrowTypes.arrowname(Tuple{}) == ArrowTypes.TUPLE
@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")

@@ -79,6 +79,16 @@ testtables = [
NamedTuple(),
nothing
),
(
"empty list types",
(
col1=[[]],
col2=[()],
),
NamedTuple(),
NamedTuple(),
nothing
),
(
"unions",
(

0 comments on commit 656c66e

Please sign in to comment.