compute_with_parallelism: Function to create table from lazy query with specified...

View source: R/compute_with_parallelism.R

compute_with_parallelismR Documentation

Function to create table from lazy query with specified degree of parallelism

Description

Compute (a-la dbplyr) a lazy query with specified degree of parallelism. Adds a parallel hint to all SELECT statements: ⁠SELECT /* +PARALLEL(N) */...⁠ The hint is usually taken into account, but as it is only a hint, the database optimizer ultimately makes a final decision as to which degree of parallelism to use, if any. This is based on things like the query itself and the amount of concurrent use.

If hints are already present in any sub-queries, e.g. included manually using dbplyr::sql(), this function will overwrite them.

Usage

compute_with_parallelism(
  lazy_tbl,
  create_table_name,
  n,
  overwrite = F,
  compress = "high",
  materialize = F
)

Arguments

lazy_tbl

name of the dbplyr lazy table

create_table_name

name of user created table in SQL database

n

the degree of parallelism to enforce

overwrite

if TRUE, function will check if table exists, and if it does, will drop it; if FALSE, will intentionally throw an error if the table already exists.

compress

Compression setting for the table: high = ⁠compress for query high⁠, low = ⁠compress for query low⁠, no = nocompress (forced non-compression), NA,NULL or any other value = compression option not passed to the database, determined by database defaults.

materialize

if TRUE, will additionally add MATERIALIZE hints

Examples

## Not run: 
compute_with_parallelism(table_db, "INT646_TABLE_DB", 32)

## End(Not run)

nhsbsa-data-analytics/nhsbsaR documentation built on Jan. 25, 2025, 8:54 a.m.