Uh oh!
There was an error while loading. Please reload this page.
ARROW-5625: [R] convert Array of struct type to data frame columns - #4593
ARROW-5625: [R] convert Array of struct type to data frame columns#4593romainfrancois wants to merge 7 commits into
Conversation
romainfrancois
commented
Jun 17, 2019
This is similar to #4575, @fsaintjacques you might want to adopt this one too. |
Uh oh!
There was an error while loading. Please reload this page.
| { "hello": 3.125, "world": null, "yo": "\u5fcd", "arr": [], "nuf": { "ps": 78 } } | ||
| { "hello": 0.0, "world": true, "yo": null, "arr": null, "nuf": { "ps": 90 } } | ||
| { "hello": 3.125, "world": null, "yo": "\u5fcd", "arr": [], "nuf": { "ps": 78.0 } } | ||
| { "hello": 0.0, "world": true, "yo": null, "arr": null, "nuf": { "ps": 90.0 } } |
There was a problem hiding this comment.
What about omitting fields, e.g. {"hello":"hi"}.
There was a problem hiding this comment.
library(arrow, warn.conflicts=FALSE)
library(tibble)
tf<- tempfile()
writeLines(' { "hello": 3.5, "world": false, "yo": "thing" } { "hello": 2.3}', tf)
read_json_arrow(tf, as_tibble=TRUE)
#> # A tibble: 2 x 3#> hello world yo #> <dbl> <lgl> <chr>#> 1 3.5 FALSE thing#> 2 2.3 NA <NA>Maybe this read_json_arrow() needs more tests.
library(arrow, warn.conflicts=FALSE)
library(tibble)
tf<- tempfile()
writeLines(' { "hello": 3.5, "world": false, "yo": "thing" } { "hello": "hi"}', tf)
read_json_arrow(tf, as_tibble=TRUE)
#> Error in json___TableReader__Read(self): Invalid: Empty JSON filebut it's not really this pull request territory. I'm using this at the moment because we currently don't have an R way to create list arrays or struct arrays, i.e. we need to be able to go the other direction with e.g.
library(arrow, warn.conflicts=FALSE)
library(tibble)
array(list(1:3, 4:5), type= list_of(int32()))
#> Error in Array__from_vector(x, type): NotImplemented: type not implementedwhich is the purpose of this one: https://issues.apache.org/jira/browse/ARROW-3809?filter=12344983
There was a problem hiding this comment.
This is an error of mine, I meant {"hello": 1.2} not a bad type. But good if it uncovered an error :)
codecov-io
commented
Jun 17, 2019
Codecov Report
@@ Coverage Diff @@## master #4593 +/- ##
==========================================
- Coverage 88.57% 75.8% -12.77%
==========================================
Files 860 56 -804 Lines 108022 3278 -104744 Branches 1253 0 -1253 ==========================================
- Hits 95678 2485 -93193 + Misses 12065 793 -11272 + Partials 279 0 -279
Continue to review full report at Codecov.
|
struct arrays become data frame columns, i.e.
Created on 2019-06-17 by the reprex package (v0.3.0.9000)