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

columnnames implementation for Tables.rowtable

Open mattwigway opened this issue 3 years ago • 0 comments

In #247 it is observed that custom rowtables don't have a working fallback for Tables.columnnames. However, it appears that this is true for base rowtables as well:

julia> using Tables
julia> Tables.columnnames(Tables.rowtable([(a=1, b=2), (a=3, b=4)]))
()

I added this code to my project to get columnnames working for rowtables:

julia> Tables.columnnames(::Vector{NamedTuple{N, T}}) where {N, T} = N
julia> Tables.columnnames(Tables.rowtable([(a=1, b=2), (a=3, b=4)]))
(:a, :b)

Is there a reason why the default behavior is correct/preferred? If not I'll make a PR adding this columnnames definition and a test (doesn't solve the general case of #247 because table rows do not have to be NamedTuples).

mattwigway avatar Nov 30 '21 15:11 mattwigway