Skip to content

connectDuckdb() installs the ICU extension but never loads it #340

Description

@aryakadakia

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:

# Check if ICU extension if installed, and if not, try to install it:
isInstalled <- querySql(
connection = connection,
sql = "SELECT installed FROM duckdb_extensions() WHERE extension_name = 'icu';"
)[1, 1]
if (!isInstalled) {
warning("The ICU extension of DuckDB is not installed. Attempting to install it.")
tryCatch(
executeSql(connection, "INSTALL icu"),
error = function(e) {
warning("Attempting to install the ICU extension of DuckDB failed.\n",
"You may need to check your internet connection.\n",
"For more detail, try 'executeSql(connection, \"INSTALL icu\")'.\n",
"Be aware that some time and date functionality will not be available.")
return(NULL)
}
)
}

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

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions