forked from apache/arrow-adbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(c/driver/postgresql): Accept bulk ingest of dictionary-encoded s…
…trings/binary (apache#1275) This PR adds the ability for the Postgres driver to ingest dictionary-encoded arrays. This shows up in R because factors are relatively common and encode by default in Arrow to dictionary-encoded string for performance reasons. Reprex in R: ``` r library(adbcdrivermanager) con <- adbcpostgresql::adbcpostgresql() |> adbc_database_init(uri = Sys.getenv("ADBC_POSTGRESQL_TEST_URI")) |> adbc_connection_init() df <- data.frame(x = letters, y = factor(letters)) write_adbc(df, con, "some_table") #> Error in adbc_statement_execute_query(stmt): [libpq] Failed to create table: ERROR: relation "some_table" already exists #> #> Query was: CREATE TABLE "public" . "some_table" ("x" TEXT, "y" TEXT) read_adbc(con, "SELECT * from some_table") |> as.data.frame() |> str() #> 'data.frame': 26 obs. of 2 variables: #> $ x: chr "a" "b" "c" "d" ... #> $ y: chr "a" "b" "c" "d" ... ``` <sup>Created on 2023-11-09 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup> There is probably some opportunity to consolidate some of the code that currently lives in the `BindStream` into the `PostgresType` and/or `PostgresTypeResolver`...I'm happy to poke away at that at some point but in the meantime it seemed like it wasn't too onerous to tack on dictionary support here.
- Loading branch information
1 parent
c0f47f9
commit 5a76d63
Showing
5 changed files
with
138 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters