Tables.jl icon indicating copy to clipboard operation
Tables.jl copied to clipboard

`columnnames` returns empty tuple on vector of namedtuples, but schema is correct

Open asinghvi17 opened this issue 8 months ago • 1 comments

using Tables

tbl = map(rand(10), rand(10), ["abc" for I in 1:10]) do c1, c2, c3
    (; c1, c2, c3)
end

Tables.istable(tbl) # true
Tables.columnnames(tbl) # ()
Tables.schema(tbl).names # (:c1, :c2, :c3)

# But
Tables.columntable(tbl) |> Tables.columnnames # (:c1, :c2, :c3)

Seems like a bug in the vector-of-namedtuples Tables.jl implementation potentially?

asinghvi17 avatar Apr 24 '25 03:04 asinghvi17

Just ran into this exact same thing - but it seems to be intentional? At any rate this is true for any rowtable. E.g.

tbl2 = broadcast(nt -> Dict(keys(nt) .=> values(nt)), tbl)
Tables.columnnames(tbl2)

also returns ()

But it definitely is a bit odd

tiemvanderdeure avatar Apr 29 '25 09:04 tiemvanderdeure