Closed OkonSamuel closed 3 years ago
The following naive solution should do the trick. Maybe someone has a better fix?
function typesubset(sch::Tables.Schema{nothing, nothing}, nms::NTuple{N, Symbol}) where {N}
names = sch.names
types = sch.types
return Tuple{Any[Tables.columntype(names, types, nm) for nm in nms]...}
end
function typesubset(sch::Tables.Schema{nothing, nothing}, inds::NTuple{N, Int}) where {N}
types = sch.types
return Tuple{Any[types[i] for i in inds]...}
end
typesubset(::Tables.Schema{nothing, nothing}, ::Tuple{}) = Tuple{}
namesubset(::Tables.Schema{nothing, nothing}, nms::NTuple{N, Symbol}) where {N} = nms
Base.@pure namesubset(::Tables.Schema{nothing, nothing}, inds::NTuple{N, Int}) where {N} = (names = sch.names; ntuple(i -> names[inds[i]], N))
namesubset(::Tables.Schema{nothing, nothing}, ::Tuple{}) = ()
Due to a recent change in
Tables.jl
developers now need to also consider specializing onTables.Schema{nothing, nothing}
in addition toTables.Schema{names, types}
. see here.
It should be noted that the threshold where Tables.jl will switch to this alternative Schema
representation is pretty high: 67_000 columns. This was chosen specifically because many operations on tables this wide were failing anyway; there are fundamental limits in the compiler right now that mean creating tuples/namedtuples that large start breaking in weird ways.
Anyway, that aside, yes, we should fix the case here. I just wanted to clarify that this kind of operation didn't work before anyway.
Hello Due to a recent change in
Tables.jl
developers now need to also consider specializing onTables.Schema{nothing, nothing}
in addition toTables.Schema{names, types}
. see here. Users will eventually pop into this error when selecting a few columns from a really wide table as shown below.