OHDSI / OHDSI/DatabaseConnector

connectDuckdb() installs the ICU extension but never loads it

Open Beginner friendly
#340 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
57
Forks
93
Avg merge
10d 12h
Merged PRs (30d)
1

Description

DatabaseConnector::connectDuckdb() runs INSTALL icu but never LOAD icu. Since LOAD is per-connection and INSTALL persists, the ICU extension ends up installed but unloaded on every connection, and functions that depend on it remain unavailable.

--- connection from DatabaseConnector: installed, not loaded ---
> library(DatabaseConnector)
> cd <- createConnectionDetails(dbms = "duckdb", server = tempfile(fileext = ".duckdb"))
> con <- connect(cd)
Connecting using DuckDB driver
> querySql(con, "SELECT value FROM duckdb_settings() WHERE name = 'autoload_known_extensions'")
  value
1  true
> querySql(con, "SELECT extension_name, installed, loaded
+                FROM duckdb_extensions() WHERE extension_name = 'icu'")
  extension_name installed loaded
1            icu      TRUE  FALSE
> querySql(con, "SELECT CAST((CURRENT_DATE + TO_DAYS(CAST(1 AS INTEGER))) AS DATE) AS x")
Error executing SQL:
Binder Error: No function matches the given name and argument types '(DATE, INTERVAL)'.
LINE 1: SELECT CAST((CURRENT_DATE + TO_DAYS(CAST(1 AS INTEGER))) AS DATE) AS x
--- same connection after LOAD ---
> executeSql(con, "LOAD icu")
> querySql(con, "SELECT CAST((CURRENT_DATE + TO_DAYS(CAST(1 AS INTEGER))) AS DATE) AS x")
           x
1 2026-09-05
--- LOAD does not carry to a new connection, INSTALL does ---
> c2 <- dbConnect(duckdb::duckdb(), dbdir = f)   # same file, fresh connection
> dbGetQuery(c2, "SELECT installed, loaded FROM duckdb_extensions()
+                 WHERE extension_name = 'icu'")
  installed loaded
1      TRUE  FALSE
Relevant lines:

https://github.com/OHDSI/DatabaseConnector/blob/128c84fa4f2fa254667dd17dc30210f7c1420a63/R/Connect.R#L863-L880

The guard queries installed rather than loaded. INSTALL writes to the DuckDB home directory and persists across sessions, so after the first successful install the branch is skipped on every subsequent connection and LOAD is never reached. LOAD icu does not appear anywhere else in the package.

Note that autoload_known_extensions is true on the connection, so DuckDB's extension autoloading does not cover this case.

Encountered via DataQualityDashboard::executeDqChecks() against a DuckDB CDM, where plausibleValueHigh on CDM_SOURCE.CDM_RELEASE_DATE renders as CURRENT_DATE + TO_DAYS(...) and reports an error rather than a result.

Environment:

DatabaseConnector: 7.2.0
duckdb: 1.5.5
DataQualityDashboard: 2.8.9
R: 4.6.0, macOS

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in R/Connect.R at lines 863-880 and inspect how connectDuckdb() checks and handles the ICU extension. Reproduce the connection with the DuckDB queries in the issue, then verify that a fresh connection reports ICU as loaded and the date expression succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.