I cannot write a MAP type to a duckdb using DBI::dbAppendTable().
con <- DBI::dbConnect(duckdb::duckdb())
DBI::dbExecute(con, "CREATE TABLE tbl (mp MAP(VARCHAR, VARCHAR));")
#> [1] 0
DBI::dbExecute(con, "INSERT INTO tbl VALUES (MAP {'a': 'b'})")
#> [1] 1
DBI::dbGetQuery(con, "DESCRIBE tbl")
#> column_name column_type null key default extra
#> 1 mp MAP(VARCHAR, VARCHAR) YES <NA> <NA> <NA>
DBI::dbReadTable(con, "tbl") |> str()
#> 'data.frame': 1 obs. of 1 variable:
#> $ mp:List of 1
#> ..$ :'data.frame': 1 obs. of 2 variables:
#> .. ..$ key : chr "a"
#> .. ..$ value: chr "b"
df <- data.frame(
mp = I(list(data.frame(key = "page", value = "1")))
)
str(df) # same structure as the returned tbl data
#> 'data.frame': 1 obs. of 1 variable:
#> $ mp:List of 1
#> ..$ :'data.frame': 1 obs. of 2 variables:
#> .. ..$ key : chr "page"
#> .. ..$ value: chr "1"
#> ..- attr(*, "class")= chr "AsIs"
DBI::dbAppendTable(con, "tbl", df)
#> Error: rapi_execute: Failed to run query
#> Error: Conversion Error: Unimplemented type for cast (STRUCT("key" VARCHAR, "value" VARCHAR)[] -> MAP(VARCHAR, VARCHAR))
I am using
sapply(c("DBI", "duckdb"), packageVersion)
#> $DBI
#> [1] 1 2 3
#>
#> $duckdb
#> [1] 1 0 0 1
(1.0.0-2 is being installed at the moment but I didnt see anything related to MAPs in the changelog from 1.0.0-1).
Update, I updated to 1.0.0-2 and I see the same error.
This is closely related to #165 and #61
I cannot write a MAP type to a duckdb using
DBI::dbAppendTable().I am using
(1.0.0-2 is being installed at the moment but I didnt see anything related to MAPs in the changelog from 1.0.0-1).
Update, I updated to 1.0.0-2 and I see the same error.
This is closely related to #165 and #61