You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by qu...@apache.org on 2023/01/07 22:26:58 UTC

[arrow-julia] branch main updated: Define defaults for Missing/Nothing (#372)

This is an automated email from the ASF dual-hosted git repository.

quinnj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c3f955  Define defaults for Missing/Nothing (#372)
9c3f955 is described below

commit 9c3f955b137a08c0b6608c65fcfe13593659b1d3
Author: Curtis Vogt <cu...@gmail.com>
AuthorDate: Sat Jan 7 16:26:49 2023 -0600

    Define defaults for Missing/Nothing (#372)
---
 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}