Skip to content

Commit 138c5be

Browse files
authored
OrderedDict for dictrowtable (#277)
* `OrderedDict` for `dictrowtable` * Fixes docstrings on `dictcolumntable` and `dictrowtable` * Test of `size` implementation on `GenericColumn` with Julia nightly * Fallback from test in previous commit
1 parent 57e2753 commit 138c5be

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/dicts.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end
77
Tables.dictcolumntable(x) => Tables.DictColumnTable
88
99
Take any Tables.jl-compatible source `x` and return a `DictColumnTable`, which
10-
can be thought of as a `Dict` mapping column names as `Symbol`s to `AbstractVector`s.
10+
can be thought of as a `OrderedDict` mapping column names as `Symbol`s to `AbstractVector`s.
1111
The order of the input table columns is preserved via the `Tables.schema(::DictColumnTable)`.
1212
1313
For "schema-less" input tables, `dictcolumntable` employs a "column unioning" behavior,
@@ -126,7 +126,7 @@ end
126126
Tables.dictrowtable(x) => Tables.DictRowTable
127127
128128
Take any Tables.jl-compatible source `x` and return a `DictRowTable`, which
129-
can be thought of as a `Vector` of `Dict` rows mapping column names as `Symbol`s to values.
129+
can be thought of as a `Vector` of `OrderedDict` rows mapping column names as `Symbol`s to values.
130130
The order of the input table columns is preserved via the `Tables.schema(::DictRowTable)`.
131131
132132
For "schema-less" input tables, `dictrowtable` employs a "column unioning" behavior,
@@ -141,12 +141,12 @@ the union behavior is needed.
141141
function dictrowtable(x)
142142
names = Symbol[]
143143
seen = Set{Symbol}()
144-
types = Dict{Symbol, Type}()
144+
types = OrderedDict{Symbol, Type}()
145145
r = rows(x)
146146
L = Base.IteratorSize(typeof(r))
147-
out = Vector{Dict{Symbol, Any}}(undef, Base.haslength(r) ? length(r) : 0)
147+
out = Vector{OrderedDict{Symbol, Any}}(undef, Base.haslength(r) ? length(r) : 0)
148148
for (i, drow) in enumerate(r)
149-
row = Dict{Symbol, Any}(nm => getcolumn(drow, nm) for nm in columnnames(drow))
149+
row = OrderedDict{Symbol, Any}(nm => getcolumn(drow, nm) for nm in columnnames(drow))
150150
add!(row, 0, :_, out, L, i)
151151
if isempty(names)
152152
for (k, v) in row

0 commit comments

Comments
 (0)