Skip to content

c/driver/postgresql: Support enum type #1483

Closed

Description

@paleolimbot

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 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')")

# 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"

Created on 2024-01-23 with reprex v2.0.2

Activity

  1. lidavidm commented on Jan 23, 2024

    @lidavidm
    Member

    It would also be good to have a way to purge the cache or notice that we need to rebuild it, hmm

  2. added a commit that references this issue on Jan 31, 2024
    12ea8b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions