Skip to content

glue_sql only has second-resolution for timestamps in duckdb #346

@DavZim

Description

@DavZim

Not sure if this fits here or needs to be created at the duckdb repo.
When I use glue_sql with timestamps, I get different resolutions for timestamps.
For duckdb I get second-level resolution, while postgres provides a higher resolution.

I would expect to receive the sub-second resolution in both cases!

glue::glue_sql(
  "INSERT INTO TEST (val) VALUES ({Sys.time()});",
  .con = DBI::dbConnect(duckdb::duckdb())
)
#> <SQL> INSERT INTO TEST (val) VALUES ('2025-06-20 12:20:25'::timestamp);
#                                                           ^ there is no subsecond resolution here!

glue::glue_sql(
  "INSERT INTO TEST (val) VALUES ({Sys.time()});",
  .con = DBI::dbConnect(RPostgres::Postgres(),
                        host = Sys.getenv("POSTGRES_HOST"),
                        port = Sys.getenv("POSTGRES_PORT"),
                        dbname = Sys.getenv("POSTGRES_DATABASE"),
                        user = Sys.getenv("POSTGRES_USER"),
                        password = Sys.getenv("POSTGRES_SECRET"))
)
#> <SQL> INSERT INTO TEST (val) VALUES ('2025-06-20 12:20:25.219384'::timestamp);
# this is what I would expect!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions