You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by om...@apache.org on 2023/01/29 04:33:23 UTC
[arrow-julia] 01/01: Fix ToArrow with abstract type and all missing
This is an automated email from the ASF dual-hosted git repository.
omus pushed a commit to branch cv/abstract-default-fix
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git
commit e3a29db0d26e7bbdd92fb5b8eb112b7138b084b7
Author: Curtis Vogt <cu...@gmail.com>
AuthorDate: Sat Jan 28 19:19:15 2023 -0600
Fix ToArrow with abstract type and all missing
---
src/ArrowTypes/src/ArrowTypes.jl | 2 +-
src/ArrowTypes/test/tests.jl | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/ArrowTypes/src/ArrowTypes.jl b/src/ArrowTypes/src/ArrowTypes.jl
index f4f9e39..43c9c10 100644
--- a/src/ArrowTypes/src/ArrowTypes.jl
+++ b/src/ArrowTypes/src/ArrowTypes.jl
@@ -349,7 +349,7 @@ function ToArrow(x::A) where {A}
for i = 2:length(x)
@inbounds T = promoteunion(T, typeof(toarrow(x[i])))
end
- if T === Missing
+ if T === Missing && concrete_or_concreteunion(S)
T = promoteunion(T, typeof(toarrow(default(S))))
end
end
diff --git a/src/ArrowTypes/test/tests.jl b/src/ArrowTypes/test/tests.jl
index d1e1914..71be73e 100644
--- a/src/ArrowTypes/test/tests.jl
+++ b/src/ArrowTypes/test/tests.jl
@@ -164,7 +164,7 @@ v_nt = (major=1, minor=0, patch=0, prerelease=(), build=())
@test eltype(x) == Union{Float64, String}
@test x == [1.0, 3.14, "hey"]
- @testset "respect non-missing type" begin
+ @testset "respect non-missing concrete type" begin
struct DateTimeTZ
instant::Int64
tz::String
@@ -187,6 +187,13 @@ v_nt = (major=1, minor=0, patch=0, prerelease=(), build=())
# would break this test by returning `Union{Nothing,Missing}`.
@test eltype(ArrowTypes.ToArrow(Any[missing])) == Missing
end
+
+ @testset "ignore non-missing abstract type" begin
+ x = ArrowTypes.ToArrow(Union{Missing,Array{Int}}[missing])
+ @test x isa ArrowTypes.ToArrow{Missing, Vector{Union{Missing, Array{Int64}}}}
+ @test eltype(x) == Missing
+ @test isequal(x, [missing])
+ end
end
end