Skip to content

dbGetQueryArrow() returns time columns as time32[ms] and drops microseconds #643

Not planned

Description

@krlmlr

A PostgreSQL time column has microsecond resolution, but dbGetQueryArrow() returns it as time32[ms], silently truncating the microseconds. The data frame path keeps them.

Location: the DBI default dbFetchArrowChunk() passes no schema, and nanoarrow infers hms as time32("ms"), a deliberate default there.

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())
s <- dbGetQueryArrow(con, "SELECT '12:34:56.789123'::time AS t")
s$get_schema()$children$t$format
#> [1] "ttm"
# Expected: "ttu" (time64[us])
format(as.data.frame(s)$t)
#> [1] "12:34:56.789"
# Expected: "12:34:56.789123"

# The data frame path keeps the microseconds
format(dbGetQuery(con, "SELECT '12:34:56.789123'::time AS t")$t)
#> [1] "12:34:56.789123"

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

Severity: medium (proposed, Kirill may change). Silent truncation.

Native Arrow support is coordinated in #631 and is expected to fix this by construction, since the native fetch maps time to time64[us].

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