-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: trait isrowtable
#134
Comments
Ok, thinking about this, I think we could add this for 1.0. The part I'm most worried about is Along those same lines, I wonder if it would make sense for us to have an official |
Do you mind explaining why it's not a desirable behavior? Isn't it like how
AFAICT this is the only trait function out there for figuring out the memory layout of a table. I'm personally seeing it as something like
Yes, I think this would be great. I think it'd make sense to add |
@tkf, would you mind doing a PR for the If you don't think you can get to |
Can we have a new trait
isrowtable
to declare a certain table type implements "row table" interface? (Previous discussion: JuliaData/TypedTables.jl#57 cc @andyferris)The motivation is for implementing
append!(dest, src)
and alike for tabledest
with column-oriented memory layout and row-wise container semantics (e.g., TypedTables.jl, StructArrays.jl). Ideally:src
is a table but not a container of rows (e.g.,NamedTuple
ofVector
s), it is not desirable forappend!(dest, src)
to append rows. For example,append!([(a=1,)], (a=[1],))
should throw.src
is a row table but has column-oriented memory layout, it is desirable to append elements column-by-column as an optimization.It is tempting to use
Tabels.columnaccess(src)
to satisfy point 2. However,Tabels.columnaccess(src)
does not imply thatsrc
has rows as elements. So, it might violate point 1.If we have
isrowtable
, we can satisfy those two points bySuggested specification
A type
RowTable
satisfies the row table interface if:Tables.rows(x::RowTable) === x
eltype(::RowTable)
is a row (not justeltype(Tables.rows(::RowTable))
)x :: RowTable
is a mutable container:push!(x, row)
must work for any compatiblerow
.append!(x, rows)
must work for compatible row tablerows
(i.e.,Tables.isrowtable(rows)
).x :: RowTable
is a mutable and indexable:x[i] = row
must work for any compatiblerow
.By
x
andy
are compatible I mean that row or tablex
andy
satisfySet(Tables.columnnames(x)) == Set(Tables.columnnames(y))
and the types are promotable.Default implementation and derived interfaces
I suggest to add
isrowtable
with the default definitionThe default definition of other parts of Tables.jl can be derived from it
This way, row tables like TypedTables.jl and StructArrays.jl can just declare
and other interfaces would be derived from it.
The text was updated successfully, but these errors were encountered: