if (FALSE) {
library(sparklyr)
sc <- spark_connect(master = "local", version = "2.4.0")
# unnesting a struct column
sdf <- copy_to(
sc,
tibble::tibble(
x = 1:3,
y = list(list(a = 1, b = 2), list(a = 3, b = 4), list(a = 5, b = 6))
)
)
unnested <- sdf %>% sdf_unnest_longer(y, indices_to = "attr")
# unnesting an array column
sdf <- copy_to(
sc,
tibble::tibble(
x = 1:3,
y = list(1:10, 1:5, 1:2)
)
)
unnested <- sdf %>% sdf_unnest_longer(y, indices_to = "array_idx")
}
Run the code above in your browser using DataLab