You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like the postgres enum type is not quite supported yet, although there is a workaround:
library(adbcdrivermanager)
db<- adbc_database_init(
adbcpostgresql::adbcpostgresql(),
uri="postgresql://localhost:5432/postgres?user=postgres&password=password")
db|>
execute_adbc("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')")
db|>
adbc_database_release()
# Have to recreate the database after because that's where we cache the typescon<-db<- adbc_database_init(
adbcpostgresql::adbcpostgresql(),
uri="postgresql://localhost:5432/postgres?user=postgres&password=password"
) |>
adbc_connection_init()
con|>
execute_adbc("CREATE TABLE x (a mood)") |>
execute_adbc("INSERT INTO x VALUES ('sad')") |>
execute_adbc("INSERT INTO x VALUES ('ok')")
# Currently returned as binary (i.e., COPY output)con|>
read_adbc("SELECT * from x") |>
as.data.frame() |>dplyr::pull(a) |>
unclass() |>
vapply(rawToChar, character(1))
#> [1] "sad" "ok"
Closes#1483.
This was pretty straightforward because the COPY representation is the
same as a string.
I also moved all the COPY examples to the common header (since only a
few were missing and it seemed odd that some of them were in different
spots).
From R:
``` r
library(adbcdrivermanager)
db <- adbc_database_init(
adbcpostgresql::adbcpostgresql(),
uri = "postgresql://localhost:5432/postgres?user=postgres&password=password")
db |>
execute_adbc("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')")
db |>
adbc_database_release()
# Have to recreate the database after because that's where we cache the types
con <- db <- adbc_database_init(
adbcpostgresql::adbcpostgresql(),
uri = "postgresql://localhost:5432/postgres?user=postgres&password=password"
) |>
adbc_connection_init()
con |>
execute_adbc("CREATE TABLE x (a mood)") |>
execute_adbc("INSERT INTO x VALUES ('sad')") |>
execute_adbc("INSERT INTO x VALUES ('ok')")
# Returns as string because that's how the driver sees it
con |>
read_adbc("SELECT * from x") |>
as.data.frame()
#> a
#> 1 sad
#> 2 ok
```
<sup>Created on 2024-01-23 with [reprex
v2.0.2](https://reprex.tidyverse.org)</sup>
It looks like the postgres enum type is not quite supported yet, although there is a workaround:
Created on 2024-01-23 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: