Skip to content

Heterogeneous data sometimes detect wrong columns type  #20

@attdona

Description

@attdona

There are combinations of heterogeneus data where the wrong column types are discovered.

For example:

using JSONTables
using Tables

nonhomogenous = """
[
    {"a": 1, "b": 2, "c": 3},
    {"b": 4, "c": 8, "d": 5}
]
"""

JSONTables.jsontable(nonhomogenous)

You got:

JSONTables.Table{false, JSON3.Array{JSON3.Object, Base.CodeUnits{UInt8, String}, Vector{UInt64}}}([:a, :b, :c, :d], Dict{Symbol, Type}(:a => Union{Missing, Int64}, :b => Int64, :d => Int64, :c => Int64), JSON3.Object[{
   "a": 1,
   "b": 2,
   "c": 3
}, {
   "b": 4,
   "c": 8,
   "d": 5
}])

d type is detected as Int64 and this throws an error when building a table:

ct = Tables.columntable(jt)
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Int64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions