Writing struct or data frame columns fails with a confusing COPY error
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 77/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, r
- Ambito
- backend-api-design, database
Direzione di ricerca
Inizia da dbDataType() in R/dbDataType_PqConnection.R e dalla codifica delle liste in sql_data_copy() in R/tables.R; l’issue descrive entrambi i percorsi che falliscono. Controlla i test esistenti per dbWriteTable() e dbWriteTableArrow() e aggiungi la copertura per le colonne di tipo struct e data frame. Il lavoro è completato quando entrambi i percorsi rifiutano queste colonne con un errore chiaro che indica che non sono supportate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Writing an Arrow struct column with dbWriteTableArrow(), or a data frame column with dbWriteTable(), creates a column typed after the inner column (integer here) and then fails in COPY with "invalid input syntax for type integer", which does not say what is wrong.
Location: RPostgres, dbDataType() on a data frame returns the types of its columns, so a nested data frame column gets its inner column's type; the encoding then treats the column as a list (sql_data_copy()).
Reprex against the CRAN release (the output on main at 41cd4be is the same):
Sys.setenv(PGHOST = "localhost", PGPORT = "5432", PGUSER = "runner", PGPASSWORD = "test123", PGDATABASE = "testdb")
library(DBI)
con <- dbConnect(RPostgres::Postgres())
tbl <- arrow::arrow_table(x = arrow::Array$create(data.frame(a = 1:2)))
dbWriteTableArrow(con, "t_struct", tbl, overwrite = TRUE)
#> Error:
#> ! COPY returned error : ERROR: invalid input syntax for type integer: "\x12"
#> CONTEXT: COPY t_struct, line 1, column x: "\x12"
# Expected: an error that says struct columns are not supported
dbRemoveTable(con, "t_struct", fail_if_missing = FALSE)
# Same with a data frame column
df <- data.frame(id = 1:2)
df$x <- data.frame(a = 1:2)
dbWriteTable(con, "t_struct", df, overwrite = TRUE)
#> Error:
#> ! COPY returned error : ERROR: invalid input syntax for type integer: "\x12"
#> CONTEXT: COPY t_struct, line 1, column x: "\x12"
dbRemoveTable(con, "t_struct", fail_if_missing = FALSE)
#> NOTICE: table "t_struct" does not exist, skipping
dbGetQuery(con, "SHOW server_version")
#> server_version
#> 1 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)
dbDisconnect(con)
as.data.frame(sessioninfo::package_info(c("RPostgres", "DBI", "nanoarrow", "arrow"), dependencies = FALSE))[c("package", "ondiskversion", "source")]
#> package ondiskversion source
#> arrow arrow 26.0.1.1 RSPM
#> DBI DBI 1.3.0 RSPM
#> nanoarrow nanoarrow 0.9.0 RSPM
#> RPostgres RPostgres 1.4.10 RSPM (R 4.5.0)
Created on 2026-11-29 with reprex v2.1.1
- fix (a clear error for struct and data frame columns)
- test
Severity: low (proposed, Kirill may change). It fails loudly, only the message is unclear.
Native Arrow support is coordinated in https://github.com/r-dbi/RPostgres/pull/631; it is not expected to fix this by construction. The native create should reject struct columns with a clear message, and the data frame path stays as it is.
- Lingua principale
- R
- Stelle
- 345
- Fork
- 81
- Merge medio
- 8h 21m
- PR unite (30g)
- 18
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di r-dbi/RPostgres
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Dates and timestamps outside years 0001 to 9999, and `infinity`, are read as garbage, with a probable out-of-bounds readForse già presa @krlmlr l’ha presa oggi. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di r-dbi/RPostgres
Issue simili
-
Installation fails from source: missing libintl.h on macOS, undeclared R_typeToChar() on R 4.6Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vincentarelbundock/xtx#11 ·
-
Check that backends override both `dbFetchArrowChunk()` and `dbClearArrowChunk()`, or neitherAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
priority:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
ichirio/rtfreporter#1166 ·
I maintainer di solito rispondono entro 1 giorno