Commits

Romain Francois authored c631c9b07c1
ARROW-3811 [R]: Support inferring data.frame column as StructArray in array constructors So that `array()` and `chunked_array()` handle data frame columns (struct arrays in arrow speech), and record batches and tables handle them too. ``` r library(arrow, warn.conflicts = FALSE) library(tibble) df <- tibble(x = 1:10, y = letters[1:10]) a <- array(df) a$type #> arrow::StructType #> struct<x: int32, y: string> a$as_vector() #> x y #> 1 1 a #> 2 2 b #> 3 3 c #> 4 4 d #> 5 5 e #> 6 6 f #> 7 7 g #> 8 8 h #> 9 9 i #> 10 10 j batch <- record_batch(a = rnorm(10), y = df) batch$schema #> arrow::Schema #> a: double #> y: struct<x: int32, y: string> as_tibble(batch) #> # A tibble: 10 x 2 #> a y$x $y #> <dbl> <int> <chr> #> 1 -0.747 1 a #> 2 0.285 2 b #> 3 0.159 3 c #> 4 0.707 4 d #> 5 0.366 5 e #> 6 0.237 6 f #> 7 -0.730 7 g #> 8 -0.880 8 h #> 9 -0.833 9 i #> 10 1.21 10 j tab <- table(a = rnorm(10), y = df) tab$schema #> arrow::Schema #> a: double #> y: struct<x: int32, y: string> as_tibble(tab) #> # A tibble: 10 x 2 #> a y$x $y #> <dbl> <int> <chr> #> 1 0.828 1 a #> 2 1.57 2 b #> 3 -1.54 3 c #> 4 0.723 4 d #> 5 1.07 5 e #> 6 1.08 6 f #> 7 -0.338 7 g #> 8 -2.26 8 h #> 9 0.198 9 i #> 10 -1.58 10 j ``` <sup>Created on 2019-06-25 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9000)</sup> Author: Romain Francois <romain@rstudio.com> Closes #4690 from romainfrancois/ARROW-3811/struct_column_inference and squashes the following commits: b24645a2 <Romain Francois> + test using data frame column in record batch 773ffdee <Romain Francois> implement CheckCompatibleStruct() 6e54b209 <Romain Francois> array() handles data frame columns -> struct arrays 2d3bdd9a <Romain Francois> type() can infer struct column types from data frames