Skip to content

implement a check for duckdb being able to install/load spatial extension #4

@e-kotov

Description

@e-kotov

e.g.

https://github.com/tidyverse/ragnar/pull/94/files#diff-48e6d6f10c23b6b67440a69e7fc19e1ffddbc1d4514431d68953502692e56557R314

can_load_duckdb_extensions <- local({
  # DuckDB extensions are shared libraries downloaded when
  # running `INSTAll <name>`. They are pre-built by the DuckDB
  # team https://github.com/duckdb/extension-ci-tools
  # They are built for the major platforms using the standard
  # compilers.
  # One of the CRAN test server is a Linux machine with R compiled
  # with clang instead of GCC. Turns since the compilers have different
  # ABIs, a crash happens when trying to execute extensions that are
  # pre-built on GCC.
  # To avoid the crash on CRAN machines, we check if the extensions can
  # be loaded in a separate process and proceed if that's possible.
  can <- NULL
  function() {
    if (is.null(can)) {
      can <<- 0 == system2(
        rscript_exe(),
        "-",
        input = c(
          "con <- DBI::dbConnect(duckdb::duckdb())",
          "DBI::dbExecute(con, 'INSTALL fts; LOAD fts;')",
          "DBI::dbExecute(con, 'INSTALL vss; LOAD vss;')"
        ),
        stderr = FALSE,
        stdout = FALSE
      )
    }
    can
  }
})

Metadata

Metadata

Assignees

Labels

featurea feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions