queryCDM: Query the Common Data Model with Annotations

Description Usage Arguments Value See Also Examples

View source: R/sql.R

Description

Query a Common Data Model table with automatic joins with any Concept Id to the Concept table with the appropriate prefix.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
queryCDM(
  sql_statement,
  write_schema = "patelm9",
  vocab_schema = "omop_vocabulary",
  conn,
  conn_fun = "connectAthena()",
  skip_cache = FALSE,
  override_cache = FALSE,
  cache_only = FALSE,
  cache_resultset = TRUE,
  render_sql = TRUE,
  render_only = FALSE,
  verbose = TRUE,
  sleepTime = 1
)

Arguments

sql_statement

SQL query

write_schema

Schema to write the staged data to for a join to Concept table.

vocab_schema

Schema where to Concept table can be found.

conn

Connection object. If provided, diverts queries to the connection instead of the local Athena instance without caching features.

skip_cache

Skip the caching altogether and directly query the database.

override_cache

If TRUE, the cache will not be loaded and will be overwritten by a new query. For override_cache to take effect, skip_cache should be FALSE.

cache_only

Loads from the cache and does not query the database. A NULL object is returned if a resultset was not cached.

cache_resultset

(deprecated) If TRUE, the resultset from the query will first be loaded from the cache. The query will be executed if a cached resultset is not retrieved for this particular query, after which the resultset will be cached. If FALSE, Athena or conn will be directly queried without any caching operations.

render_sql

If TRUE, the SQL will be printed back in the console prior to execution. Default: FALSE

verbose

If TRUE, prints loading and querying operations messages to the console. Default: FALSE

sleepTime

Argument for 'Sys.sleep()' in between queries to allow for halting function execution, especially in cases where other chariot functions are executing multiple queries in succession and require cancellation.

Value

a [tibble][tibble::tibble-package]

See Also

parse_expr str_remove select_all,vars,reexports,mutate-joins

Other query functions: queryAncestors(), queryAthena(), queryCode(), queryConceptClassRelationships(), queryConceptId(), queryDescendants(), queryRelationships(), querySynonyms(), queryVocabularyRelationships(), query_athena()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(pg13)
library(tidyverse)

conn <- local_connect("polyester")

queryCDM(sql_statement = "SELECT * FROM omop_cdm.drug_exposure ORDER BY RANDOM() LIMIT 5;",
         write_schema = "omop_cdm",
         vocab_schema = "omop_cdm",
         conn = conn)

dc(conn = conn)

patelm9/chariot documentation built on Feb. 19, 2022, 11:29 a.m.