Fix ToArrow with abstract type and all missing (#385)
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 @@
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 @@
@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 @@
# 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