Skip to content

Commit 8f22b25

Browse files
author
Pietro Vertechi
authored
table cleanup (#38)
1 parent 4cc1830 commit 8f22b25

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/structarray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function similar_structarray(v::AbstractArray, ::Type{Z}; unwrap = t -> false) w
5858
buildfromschema(typ -> _similar(v, typ; unwrap = unwrap), Z)
5959
end
6060

61+
StructArray(v; unwrap = t -> false) = collect_structarray(v; initializer = StructArrayInitializer(unwrap))
6162
function StructArray(v::AbstractArray{T}; unwrap = t -> false) where {T}
6263
s = similar_structarray(v, T; unwrap = unwrap)
6364
for i in eachindex(v)

src/tables.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
Tables.istable(::Type{<:StructArray}) = true
2-
Tables.rowaccess(::Type{<:StructArray}) = true
3-
Tables.columnaccess(::Type{<:StructArray}) = true
1+
Tables.istable(::Type{<:StructVector}) = true
2+
Tables.istable(::Type{<:StructVector{<:Tuple}}) = false
3+
Tables.rowaccess(::Type{<:StructVector}) = true
4+
Tables.columnaccess(::Type{<:StructVector}) = true
45

5-
Tables.rows(s::StructArray) = s
6-
Tables.columns(s::StructArray) = fieldarrays(s)
6+
Tables.rows(s::StructVector) = s
7+
Tables.columns(s::StructVector) = fieldarrays(s)
78

8-
function Tables.schema(s::StructArray{T}) where {T}
9-
NT = staticschema(T)
10-
names = fieldnames(NT)
11-
types = tuple_type(NT).parameters
9+
function Tables.schema(s::StructVector)
10+
cols = fieldarrays(s)
11+
names = propertynames(cols)
12+
types = map(eltype, cols)
1213
Tables.Schema(names, types)
1314
end

0 commit comments

Comments
 (0)