JuliaData / JSONTables.jl

JSON3.jl + Tables.jl
MIT License
67 stars 10 forks source link

Implement Tables.schema for JSONTables.Table #18

Closed quinnj closed 3 years ago

quinnj commented 3 years ago

Fixes #17. This PR updates the jsontable constructor function that returns a JSONTables.Table object. It now does stricter checks that the incoming object or array is actually a table (strict object of arrays or array of objects); it also checks the names and types that will be expected, with particular consideration for the array of objects, where the objects may not all have the same "schema". We do a pass over the array of objects, "union"-ing the columns from across all rows, along with the value types. This obviously adds a performance hit for initial table construction, but ultimately leads to a much more predictable user experience. If the cost is indeed too prohibitive, we can address the potential of adding a fast-path constructor later on, which shouldn't be hard or disruptive.

codecov[bot] commented 3 years ago

Codecov Report

Merging #18 into master will increase coverage by 5.90%. The diff coverage is 94.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #18      +/-   ##
==========================================
+ Coverage   85.00%   90.90%   +5.90%     
==========================================
  Files           1        1              
  Lines          60       88      +28     
==========================================
+ Hits           51       80      +29     
+ Misses          9        8       -1     
Impacted Files Coverage Δ
src/JSONTables.jl 90.90% <94.00%> (+5.90%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b94e650...031b33c. Read the comment docs.