Skip to content

Arrow type of int8 columns depends on the bigint argument, and bigint = "integer" turns large values into NA silently #644

Not planned

Description

@krlmlr

The Arrow type that dbGetQueryArrow() returns for an int8 column follows the bigint argument of dbConnect(): int64 for "integer64", int32 for "integer", float64 for "numeric" and string for "character". With bigint = "integer", values beyond 32 bits become NA without a warning, in dbGetQuery() as well.

Location: RPostgres, convert_bigint() converts the column before nanoarrow sees it and wraps the conversion in suppressWarnings(); the DBI default dbFetchArrowChunk() then infers the Arrow type from the R class.

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())
q <- "SELECT 9007199254740993::int8 AS x"
for (bigint in c("integer64", "integer", "numeric", "character")) {
  con2 <- dbConnect(RPostgres::Postgres(), bigint = bigint)
  s <- dbGetQueryArrow(con2, q)
  print(c(bigint = bigint, format = s$get_schema()$children$x$format))
  dbDisconnect(con2)
}
#>      bigint      format 
#> "integer64"         "l" 
#>    bigint    format 
#> "integer"       "i" 
#>    bigint    format 
#> "numeric"       "g" 
#>      bigint      format 
#> "character"         "u"
# Expected: "l" (int64) for every setting

con2 <- dbConnect(RPostgres::Postgres(), bigint = "integer")
as.data.frame(dbGetQueryArrow(con2, q))
#>    x
#> 1 NA
dbGetQuery(con2, q)
#>    x
#> 1 NA
# Expected: the value, or at least a warning about the NA
dbDisconnect(con2)

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"), dependencies = FALSE))[c("package", "ondiskversion", "source")]
#>             package ondiskversion         source
#> 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

  • decide whether the Arrow path always returns int64 for int8
  • fix the Arrow type
  • warn (or error) on overflow with bigint = "integer"
  • test

Severity: medium (proposed, Kirill may change).

Native Arrow support is coordinated in #631. It is expected to fix the Arrow type by construction if the native fetch always maps int8 to int64, an open question there; the silent NA with bigint = "integer" is in the data frame path and is not fixed by it.

Activity

  1. added
    status: open
    on Nov 29, 2026
  2. krlmlr commented on Nov 29, 2026

    @krlmlr
    MemberAuthor

    Closed to keep the issue tracker for issues reported by others; the work here is still open and tracked with the status: open label.


    Generated by Claude Code

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

    bugstatus: open

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions