From 87b1a364fb0b803e4a6ba070e20cce31bae9baf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Sat, 17 Aug 2024 07:37:12 +0200 Subject: [PATCH] fix vcat type piracy --- src/abstractdataframe/abstractdataframe.jl | 4 ++++ test/cat.jl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/abstractdataframe/abstractdataframe.jl b/src/abstractdataframe/abstractdataframe.jl index e8f4e32ed0..65635a76bb 100644 --- a/src/abstractdataframe/abstractdataframe.jl +++ b/src/abstractdataframe/abstractdataframe.jl @@ -1956,6 +1956,10 @@ Base.reduce(::typeof(vcat), init::AbstractDataFrame=DataFrame()) = reduce(vcat, collect(AbstractDataFrame, dfs), cols=cols, source=source, init=init) +# definition fixing type piracy +Base.reduce(op::typeof(vcat), A::AbstractVector{Union{}}; kw...) = + mapreduce(identity, op, A; kw...) + function _vcat(dfs::AbstractVector{AbstractDataFrame}; cols::Union{Symbol, AbstractVector{Symbol}, AbstractVector{<:AbstractString}}=:setequal) diff --git a/test/cat.jl b/test/cat.jl index b5aa1cfd9b..5f45230e98 100644 --- a/test/cat.jl +++ b/test/cat.jl @@ -477,4 +477,9 @@ end @test reduce(vcat, (df1, df2)) == DataFrame(a=[1, 1], b=[2, 2]) end +@testset "vcat type piracy" begin + x = Int[] + @test reduce(vcat, Union{}[], init=x) === x +end + end # module