Skip to content

Commit a2be40f

Browse files
attdonaAttilio
andauthored
Fix wrong column type for heterogeneus data (#21)
Co-authored-by: Attilio <attilio.dona@telecomitalia.it>
1 parent 272624b commit a2be40f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/JSONTables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function jsontable(x::JSON3.Array{JSON3.Object})
6262
if !(k in seen)
6363
push!(seen, k)
6464
push!(names, k)
65-
types[k] = missT(typeof(v))
65+
types[k] = Union{Missing, missT(typeof(v))}
6666
end
6767
end
6868
end

test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,15 @@ ct = Tables.columntable(jt)
8181
@test isequal(ct.a, [1, missing, 6, 8, 8])
8282
@test isequal(ct.d, [missing, 5, 7, missing, 11])
8383

84+
new_field_in_last_row = """
85+
[
86+
{"a": 1, "b": 2},
87+
{"b": 4, "c": 8}
88+
]
89+
"""
90+
91+
jt = JSONTables.jsontable(new_field_in_last_row)
92+
ct = Tables.columntable(jt)
93+
@test isequal(ct.c, [missing, 8])
94+
8495
end

0 commit comments

Comments
 (0)