Skip to content

dbBindArrow() loses precision for int64 parameters #641

Not planned

Description

@krlmlr

Binding an Arrow int64 parameter with dbBindArrow() sends a rounded value: the parameter stream is converted to a data frame first, which turns int64 into double.

Location: DBI default method, param_stream_to_list() calls as.data.frame() on the stream, and nanoarrow maps int64 to double() by default.

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())
rs <- dbSendQueryArrow(con, "SELECT $1::int8::text AS a")
p <- nanoarrow::as_nanoarrow_array_stream(
  setNames(data.frame(bit64::as.integer64("9007199254740993")), ""),
  schema = nanoarrow::na_struct(list(nanoarrow::na_int64()))
)
dbBindArrow(rs, p)
as.data.frame(dbFetchArrow(rs))
#>                  a
#> 1 9007199254740992
# Expected: 9007199254740993
dbClearResult(rs)

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

  • fix
  • test
  • report upstream (DBI default method)

Severity: medium (proposed, Kirill may change).

Native Arrow support is coordinated in #631 and is expected to fix this by construction, since a native bind reads the int64 values from the Arrow parameter stream directly.

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