-
Notifications
You must be signed in to change notification settings - Fork 41
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
improve tables support #276
Conversation
Test failures seem irrelevant. |
Bump |
bump! |
Sorry for the delay in the review merge of the various PRs! So, here I agree that it makes sense to have a simpler way to do this, without asking users to do Possible options:
cc: @quinnj |
As I understand, dispatching on |
100%, please never do that :) Tables and arrays can easily conflict, and this is manifested as bugs in functions on arrays that shouldn't be affected on Tables at all - see #278 (because |
I'm just a little concerned that it could create odd expectations that I'm adding a link to a similar discussion in CSV.jl JuliaData/CSV.jl#941 (comment). I would agree with the proposal linked above to instead have a simple CSV.read(input, StructArrays.fromtable) # or even
CSV.read(input, materializer(StructArray)) If that is unintuitive, there is also the option of using |
There are more and more cases when I wish this conversion was defined... StructArray is basically the type-stable columnar array + table in Julia, would be great to make interop as straightforward as possible. Yes, we cannot support all tables because there's nothing to dispatch on (and using Tables stuff without dispatch is quite bad, #278 for a specific bug it causes). But supporting more tables, those where it can be done cleanly, is a strict improvement IMO. |
Bump... |
gentle bump... |
bump |
Added fromtable and materializer following #291. Are there any remaining concerns regarding Tables support, or this can be merged? |
Thanks for this @aplavin ! |
I'll take the liberty to merge this, following an advice on slack #arrays. The PR didn't get a strong "no" from maintainers, changes are nonbreaking, and quite local (ie not an overhaul). |
StructArrays constructor fundamentally cannot convert an arbitrary
Tables.jl
table to aStructArray
. This would interfere with current, and totally sensible, collection handling:Tables.jl
don't provide a common abstract type to dispatch.However, I think it makes sense to support tables when dispatching is straightforward. Here, I add direct construction support for
AbstractColumns
. Its subtypes include numerous columnar tables defined inTables.jl
and in other packages. As a concrete motivating example, this enablesCSV.read("file.csv", StructArray)
.UPD: also, this PR adds a separate function
StructArrays.fromtable
to support constructing from arbitrary Tables objects, andTables.materializer
support.