From eb3d27926f30d3e8f16944bc7872c48ff98707fe Mon Sep 17 00:00:00 2001 From: Adam Black Date: Thu, 19 Aug 2021 16:22:08 -0400 Subject: [PATCH] Add imports and update docs. --- .Rbuildignore | 1 + NAMESPACE | 3 ++ R/WikiParser.R | 2 +- R/createDdl.R | 1 + R/downloadCurrentDdl.R | 2 +- man/downloadCurrentDdl.Rd | 1 - man/writeDdl.Rd | 61 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 man/writeDdl.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 51cbb5f..070fca2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^LICENSE\.md$ .github/* +extras/* diff --git a/NAMESPACE b/NAMESPACE index fc60bbb..92dc0be 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,3 +13,6 @@ export(writeDdl) export(writeForeignKeys) export(writeIndex) export(writePrimaryKeys) +importFrom(utils,download.file) +importFrom(utils,read.csv) +importFrom(utils,write.csv) diff --git a/R/WikiParser.R b/R/WikiParser.R index b471633..1e5ee13 100644 --- a/R/WikiParser.R +++ b/R/WikiParser.R @@ -23,7 +23,7 @@ #' #' @param mdFilesLocation Path to the root folder of the Wiki repository. #' @param output_file Path to where the output CSV file should be written. -#' +#' @importFrom utils write.csv #' @export parseWiki <- function(mdFilesLocation, output_file) { # mdFilesLocation <- "../CommonDataModel.wiki" diff --git a/R/createDdl.R b/R/createDdl.R index 74464e6..d1a66dc 100644 --- a/R/createDdl.R +++ b/R/createDdl.R @@ -26,6 +26,7 @@ #' #' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4 #' @return A character string containing the OHDSQL DDL +#' @importFrom utils read.csv #' @export #' @examples #' ddl <- createDdl("5.4") diff --git a/R/downloadCurrentDdl.R b/R/downloadCurrentDdl.R index 8bd9de3..469208b 100644 --- a/R/downloadCurrentDdl.R +++ b/R/downloadCurrentDdl.R @@ -14,7 +14,7 @@ #' downloadCurrentDdl("OHDSI/CommonDataModel", #' pathToCsv="Sql%20Server/OMOP%20CDM%20sql%20server%20ddl.txt") #' } -#' +#' @importFrom utils download.file #' @export downloadCurrentDdl <- function(githubPath="OHDSI/CommonDataModel", diff --git a/man/downloadCurrentDdl.Rd b/man/downloadCurrentDdl.Rd index 867c863..f3068d2 100644 --- a/man/downloadCurrentDdl.Rd +++ b/man/downloadCurrentDdl.Rd @@ -30,5 +30,4 @@ The default location is downloadCurrentDdl("OHDSI/CommonDataModel", pathToCsv="Sql\%20Server/OMOP\%20CDM\%20sql\%20server\%20ddl.txt") } - } diff --git a/man/writeDdl.Rd b/man/writeDdl.Rd new file mode 100644 index 0000000..c245499 --- /dev/null +++ b/man/writeDdl.Rd @@ -0,0 +1,61 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/writeDdl.R +\name{writeDdl} +\alias{writeDdl} +\alias{writePrimaryKeys} +\alias{writeForeignKeys} +\alias{writeIndex} +\title{Write DDL script} +\usage{ +writeDdl( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writePrimaryKeys( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writeForeignKeys( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writeIndex( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) +} +\arguments{ +\item{targetDialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} + +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4} + +\item{outputpath}{The directory or folder where the SQL file should be saved.} + +\item{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. +Defaults to "@cdmDatabaseSchema"} +} +\description{ +Write the DDL to a SQL file. The SQL will be rendered (parameters replaced) and translated to the target SQL +dialect. By default the @cdmDatabaseSchema parameter is kept in the SQL file and needs to be replaced before +execution. +} +\section{Functions}{ +\itemize{ +\item \code{writePrimaryKeys}: writePrimaryKeys Write the SQL code that creates the primary keys to a file. + +\item \code{writeForeignKeys}: writeForeignKeys Write the SQL code that creates the foreign keys to a file. + +\item \code{writeIndex}: writeIndex Write the rendered and translated sql that creates recommended indexes to a file. +}} +