Skip to content

Commit

Permalink
Merge pull request #590 from OHDSI/supported-dialects-update
Browse files Browse the repository at this point in the history
updating for recent SqlRender supported dialects
  • Loading branch information
fdefalco committed Sep 8, 2023
2 parents 8c18f01 + efced48 commit 788ae51
Show file tree
Hide file tree
Showing 131 changed files with 13,861 additions and 8,788 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^LICENSE\.md$
.github/*
extras/*
docs/*
rmd/*
11 changes: 5 additions & 6 deletions .github/workflows/R_CMD_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ jobs:
CDMDDLBASE_ORACLE_CDM_SCHEMA: ${{ secrets.CDMDDLBASE_ORACLE_CDM_SCHEMA }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-tinytex@v1
- uses: r-lib/actions/setup-tinytex@v2

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand All @@ -66,7 +65,7 @@ jobs:

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
uses: actions/cache@v3.3.1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ ehthumbs.db
Thumbs.db
extras/codeToRun.R
output/
ddl/
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: CommonDataModel
Type: Package
Title: OMOP CDM DDL and Documentation Generator
Version: 0.1.0
Version: 0.2.0
Author: Clair Blacketer [aut, cre]
Maintainer: Clair Blacketer <mblacke@its.jnj.com>
Description: This package uses an input csv file to create the OHDSql version of the DDL as well as the documentation associated. Then it leverages the SqlRender package to convert the DDL script written in OHDSql to the other supported dialects.
Expand All @@ -13,7 +13,6 @@ Imports:
SqlRender,
rmarkdown,
stringr,
readxl,
DatabaseConnector,
DBI,
dplyr,
Expand All @@ -24,5 +23,5 @@ Suggests:
RSQLite,
withr
NeedsCompilation: no
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Config/testthat/edition: 3
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

3 changes: 2 additions & 1 deletion R/buildRelease.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ buildRelease <- function(cdmVersions = listSupportedVersions(),
#' @return A character string containing the OHDSQL DDL
#' @export
#' @examples
#'\dontrun{
#' buildReleaseZip(cdmVersion='5.3', targetDialect='sql server', outputfolder='.')
#'
#'}
buildReleaseZip <- function(cdmVersion,
targetDialect = listSupportedDialects(),
outputfolder = file.path(getwd(), "output")){
Expand Down
8 changes: 8 additions & 0 deletions R/createDdl.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
#' @importFrom utils read.csv
#' @export
#' @examples
#'\dontrun{
#' ddl <- createDdl("5.4")
#' pk <- createPrimaryKeys("5.4")
#' fk <- createForeignKeys("5.4")
#'}
createDdl <- function(cdmVersion){
# prevent check NOTE from occurring due to non-standard evaluation of variables
cdmTableName <- cdmFieldName <- isRequired <- cdmDatatype <- NULL

# argument checks
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
Expand Down Expand Up @@ -95,6 +99,8 @@ createDdl <- function(cdmVersion){
#' @describeIn createDdl createPrimaryKeys Returns a string containing the OHDSQL for creation of primary keys in the OMOP CDM.
#' @export
createPrimaryKeys <- function(cdmVersion){
# prevent check NOTE from occurring due to non-standard evaluation of variables
isPrimaryKey <- cdmFieldName <- NULL

# argument checks
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
Expand All @@ -119,6 +125,8 @@ createPrimaryKeys <- function(cdmVersion){
#' @describeIn createDdl createForeignKeys Returns a string containing the OHDSQL for creation of foreign keys in the OMOP CDM.
#' @export
createForeignKeys <- function(cdmVersion){
# prevent check NOTE from occurring due to non-standard evaluation of variables
isForeignKey <- NULL

# argument checks
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
Expand Down
2 changes: 1 addition & 1 deletion R/executeDdl.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ executeDdl <- function(connectionDetails,

con <- DatabaseConnector::connect(connectionDetails = connectionDetails)

DatabaseConnector::executeSql(con, sql = sql, ...)
DatabaseConnector::executeSql(con, sql = sql, reportOverallTime = FALSE, progressBar = FALSE, ...)

DatabaseConnector::disconnect(con)
}
Expand Down
8 changes: 8 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# these packages are used in utilities or functions outside of check's vision
# this function ensures that check is satisfied and does not report the
# packages as imported but not imported from
checkSatisfier <- function() {
DBI::dbConnect
dplyr::sql
rmarkdown::draft
}
11 changes: 5 additions & 6 deletions R/writeDDL.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#' dialect. By default the @cdmDatabaseSchema parameter is kept in the SQL file and needs to be replaced before
#' execution.
#'
#' @param targetDialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server",
#' "spark", "snowflake", "synapse"
#' @param targetDialect The dialect of the target database. Support dialects are specified by SqlRender::listSupportedDialects
#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4
#' @param outputfolder The directory or folder where the SQL file should be saved.
#' @param cdmDatabaseSchema The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server.
Expand All @@ -31,7 +30,7 @@
writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {

# argument checks
stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server", "spark", "snowflake", "synapse"))
stopifnot(targetDialect %in% listSupportedDialects())
stopifnot(cdmVersion %in% listSupportedVersions())
stopifnot(is.character(cdmDatabaseSchema))

Expand All @@ -55,7 +54,7 @@ writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema
writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {

# argument checks
stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server", "spark", "snowflake", "synapse"))
stopifnot(targetDialect %in% listSupportedDialects())
stopifnot(cdmVersion %in% listSupportedVersions())
stopifnot(is.character(cdmDatabaseSchema))

Expand All @@ -79,7 +78,7 @@ writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas
writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {

# argument checks
stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server", "spark", "snowflake", "synapse"))
stopifnot(targetDialect %in% listSupportedDialects())
stopifnot(cdmVersion %in% listSupportedVersions())
stopifnot(is.character(cdmDatabaseSchema))

Expand All @@ -103,7 +102,7 @@ writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas
writeIndex <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {

# argument checks
stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server", "spark", "snowflake", "synapse"))
stopifnot(targetDialect %in% listSupportedDialects())
stopifnot(cdmVersion %in% listSupportedVersions())
stopifnot(is.character(cdmDatabaseSchema))

Expand Down

0 comments on commit 788ae51

Please sign in to comment.