Skip to contents

This function is a wrapper around dplyr::compute that is tested on several database systems. It is needed to handle edge cases where dplyr::compute does not produce correct SQL.

Usage

computeQuery(
  x,
  name = uniqueTableName(),
  temporary = TRUE,
  schema = NULL,
  overwrite = TRUE,
  ...
)

compute_query(
  x,
  name = uniqueTableName(),
  temporary = TRUE,
  schema = NULL,
  overwrite = TRUE,
  ...
)

Arguments

x

A dplyr query

name

The name of the table to create.

temporary

Should the table be temporary: TRUE (default) or FALSE

schema

The schema where the table should be created. Ignored if temporary = TRUE.

overwrite

Should the table be overwritten if it already exists: TRUE (default) or FALSE Ignored if temporary = TRUE.

...

Further arguments passed on the dplyr::compute

Value

A dplyr::tbl() reference to the newly created table.

Examples

if (FALSE) { # \dontrun{
library(CDMConnector)

con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdm_from_con(con, "main")

# create a temporary table in the remote database from a dplyr query
drugCount <- cdm$concept %>%
  dplyr::count(domain_id == "Drug") %>%
  computeQuery()

# create a permanent table in the remote database from a dplyr query
drugCount <- cdm$concept %>%
  dplyr::count(domain_id == "Drug") %>%
  computeQuery("tmp_table", temporary = FALSE, schema = "main")

DBI::dbDisconnect(con, shutdown = TRUE)
} # }