This is an automated email from the ASF dual-hosted git repository. omus pushed a commit to branch cv/default-missing-nothing in repository https://gitbox.apache.org/repos/asf/arrow-julia.git
commit 965a2d7a63293dec7bbb97c4736e03d6bf50d3c8 Author: Curtis Vogt <[email protected]> AuthorDate: Wed Jan 4 15:11:30 2023 -0600 Define defaults for Missing/Nothing --- src/ArrowTypes/src/ArrowTypes.jl | 4 ++++ src/ArrowTypes/test/tests.jl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/ArrowTypes/src/ArrowTypes.jl b/src/ArrowTypes/src/ArrowTypes.jl index 115c102..751d4f5 100644 --- a/src/ArrowTypes/src/ArrowTypes.jl +++ b/src/ArrowTypes/src/ArrowTypes.jl @@ -304,7 +304,11 @@ default(::Type{Symbol}) = Symbol() default(::Type{Char}) = '\0' default(::Type{<:AbstractString}) = "" default(::Type{Any}) = nothing +default(::Type{Missing}) = missing +default(::Type{Nothing}) = nothing default(::Type{Union{T, Missing}}) where {T} = default(T) +default(::Type{Union{T, Nothing}}) where {T} = default(T) +default(::Type{Union{T, Missing, Nothing}}) where {T} = default(T) function default(::Type{A}) where {A <: AbstractVector{T}} where {T} a = similar(A, 1) diff --git a/src/ArrowTypes/test/tests.jl b/src/ArrowTypes/test/tests.jl index 7552d89..172723c 100644 --- a/src/ArrowTypes/test/tests.jl +++ b/src/ArrowTypes/test/tests.jl @@ -130,7 +130,11 @@ v_nt = (major=1, minor=0, patch=0, prerelease=(), build=()) @test ArrowTypes.default(Symbol) == Symbol() @test ArrowTypes.default(Char) == '\0' @test ArrowTypes.default(String) == "" +@test ArrowTypes.default(Missing) === missing +@test ArrowTypes.default(Nothing) === nothing @test ArrowTypes.default(Union{Int, Missing}) == Int(0) +@test ArrowTypes.default(Union{Int, Nothing}) == Int(0) +@test ArrowTypes.default(Union{Int, Missing, Nothing}) == Int(0) @test ArrowTypes.promoteunion(Int, Float64) == Float64 @test ArrowTypes.promoteunion(Int, String) == Union{Int, String}
