-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAP type is not working in R #61
Comments
Thanks! Tagging duckdb/duckdb#8859 since the two are similar issues |
the
|
Thanks, confirmed. library(DBI)
con <- dbConnect(duckdb::duckdb())
dbGetQuery(con, "SELECT map([1,2],['a','b']) AS x;")
#> Error: rapi_prepare: Unknown column type for prepare: MAP(INTEGER, VARCHAR)
dbExecute(con, "COPY (SELECT map([1,2],['a','b']) AS x) TO 'map.parquet'")
#> [1] 1
parquet <- arrow::read_parquet("map.parquet")
tibble::as_tibble(parquet)
#> # A tibble: 1 × 1
#> x
#> <list<
#> tbl_df<
#> key : integer
#> value: character
#> >
#> >>
#> 1 [2 × 2]
parquet$x[[1]]
#> # A tibble: 2 × 2
#> key value
#> <int> <chr>
#> 1 1 a
#> 2 2 b Created on 2024-04-24 with reprex v2.1.0 For reference, Arrow converts dictionaries to two-column data frames, this is what we should do here too. Side note: The headers for list-of-data-frame columns look odd. I suspect we need to work around in pillar. |
I mentioned this at the old repo but, for posterity, a relatively simple workaround is Using @krlmlr's example: library(DBI)
con = dbConnect(duckdb::duckdb(), shutdown = TRUE)
dbGetQuery(
con,
"
FROM (SELECT map([1,2],['a','b']) AS x)
SELECT UNNEST(MAP_ENTRIES(x), recursive := TRUE)
"
)
#> key value
#> 1 1 a
#> 2 2 b |
PR is here: #165 |
The text was updated successfully, but these errors were encountered: