if (FALSE) {
# Connect to Presto
con <- DBI::dbConnect(RPresto::Presto(), ...)
# Create a table with an array column
DBI::dbExecute(con, "CREATE TABLE test (id BIGINT, arr ARRAY(BIGINT))")
DBI::dbExecute(con, "INSERT INTO test VALUES (1, ARRAY[10, 20, 30])")
# Unnest the array column
tbl(con, "test") %>%
presto_unnest(arr) %>%
collect()
# Without values_to, the unnested column is named "arr_elem"
# Or specify a custom name
tbl(con, "test") %>%
presto_unnest(arr, values_to = "elem") %>%
collect()
}
Run the code above in your browser using DataLab