diff --git a/src/namedtuples.jl b/src/namedtuples.jl index 8bdc793..9befe76 100644 --- a/src/namedtuples.jl +++ b/src/namedtuples.jl @@ -176,9 +176,14 @@ function columntable(sch::Schema{names, types}, cols) where {names, types} end end -# extremely large tables -columntable(sch::Schema{nothing, nothing}, cols) = - throw(ArgumentError("input table too wide ($(length(sch.names)) columns) to convert to `NamedTuple` of `AbstractVector`s")) +# extremely large tables or schema explicitly stored +function columntable(sch::Schema{nothing, nothing}, cols) + nms = sch.names + if nms !== nothing && length(nms) > SPECIALIZATION_THRESHOLD + throw(ArgumentError("input table too wide ($(length(nms)) columns) to convert to `NamedTuple` of `AbstractVector`s")) + end + return NamedTuple{Tuple(map(Symbol, nms))}(Tuple(getarray(getcolumn(cols, nms[i])) for i = 1:length(nms))) +end # unknown schema case columntable(::Nothing, cols) = diff --git a/test/runtests.jl b/test/runtests.jl index 832dc80..7c16863 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1040,3 +1040,14 @@ end @test DataAPI.nrow(Tables.dictrowtable([(a=1, b=2), (a=3, b=4), (a=5, b=6)])) == 3 @test DataAPI.ncol(Tables.dictrowtable([(a=1, b=2), (a=3, b=4), (a=5, b=6)])) == 2 end + +@testset "#357" begin + dct = Tables.dictcolumntable((a=1:3, b=4.0:6.0, c=["7", "8", "9"])) + sch = Tables.schema(dct) + sch = Tables.Schema(sch.names, sch.types, stored=true) + dct = Tables.DictColumnTable(sch, getfield(dct, :values)) + nt = Tables.columntable(dct) + @test nt.a == [1, 2, 3] + @test nt.b == [4.0, 5.0, 6.0] + @test nt.c == ["7", "8", "9"] +end