From 5f333f184a8ea66e1db7eba561c240a81d688f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Mon, 8 Apr 2024 21:28:31 +0200 Subject: [PATCH 1/2] Improve handling of vectors of vectors --- src/fallbacks.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fallbacks.jl b/src/fallbacks.jl index d911ac1..dbe655d 100644 --- a/src/fallbacks.jl +++ b/src/fallbacks.jl @@ -213,7 +213,8 @@ end WT = wrappedtype(eltype(rowitr)) if WT <: Tuple return allocatecolumns(Schema((Symbol("Column$i") for i = 1:fieldcount(WT)), _fieldtypes(WT)), 0) - elseif isconcretetype(WT) && fieldcount(WT) > 0 + # special case Vector from base and view of this vector as we are sure they do not store rows of a table + elseif isconcretetype(WT) && fieldcount(WT) > 0 && !(WT <: Union{Vector, SubArray{<:Vector}}) return allocatecolumns(Schema(fieldnames(WT), _fieldtypes(WT)), 0) end end From 743c71831f78f65065844dc40815609567d72739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Mon, 8 Apr 2024 21:32:44 +0200 Subject: [PATCH 2/2] Update runtests.jl --- test/runtests.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 832dc80..480a390 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -120,6 +120,11 @@ using Test, Tables, OrderedCollections, TableTraits, DataValues, QueryOperators, sch = Tables.Schema((), ()) @test sch.names == () @test sch.types == () + + # Empty vector of Vector or their view + @test Tables.columntable(Vector{Any}[]) == NamedTuple() + T = typeof(view(Vector{Any}[], :)) + @test Tables.columntable(T[]) == NamedTuple() end @testset "namedtuples.jl" begin