-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
We currently have this behavior, which is not optimal:
julia> X = StructArray(a = rand(5), b = rand(5));
julia> Tables.materializer(X)(Tables.columns(X))
5-element Vector{@NamedTuple{a::Float64, b::Float64}}:
(a = 0.2940266626814607, b = 0.6915915110907411)
(a = 0.6392677058537343, b = 0.5609264578636665)
[...]When using Tables.materializer on a StructArray we probably don't want to get something that generates plain vectors of named tuples. If X isa StructArray then we should also have Tables.materializer(X)(Tables.columns(X)) isa StructArray (TypeTables.Table, for example, behaves like this).
I propose to specialize Tables.materializer like this
_materialize_sa(cols) = StructArray(cols)
Tables.materializer(X::StructArray) = _materialize_sa(Returning a function _materialize_sa instead of StructArray directly helps with type stability). This will result in
julia> Tables.materializer(X)(Tables.columns(X))
5-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype @NamedTuple{a::Float64, b::Float64}:
(a = 0.2940266626814607, b = 0.6915915110907411)
(a = 0.6392677058537343, b = 0.5609264578636665)
[...]Questions is, should this be considered to be breaking, requiring a v0.7 release?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels