Skip to content

Commit

Permalink
Made type checking optional until feature can be properly evaluated
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Jan 7, 2025
1 parent bde58a1 commit bb73794
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
28 changes: 17 additions & 11 deletions R/ResultExportManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ ResultExportManager <- R6::R6Class(
tables = NULL,
tableSpecification = NULL,
databaseId = NULL,
validateTypes = FALSE,
connection = NULL,
minCellCount = 5,
.colTypeValidators = list(
"numeric" = checkmate::checkNumeric,
"int" = checkmate::checkIntegerish,
"varchar" = checkmate::checkCharacter,
"numeric" = checkmate::testNumeric,
"int" = checkmate::testIntegerish,
"varchar" = checkmate::testCharacter,
"bigint" = function(x, ...) {
all(checkmate::checkNumeric(x = x, ...) & x %% 1 == 0)
all(checkmate::testNumeric(x = x, ...) & x %% 1 == 0)
},
"float" = checkmate::checkNumeric,
"character" = checkmate::checkCharacter,
"date" = checkmate::checkDate
"float" = checkmate::testNumeric,
"character" = checkmate::testCharacter,
"date" = checkmate::testDate
),
getPrimaryKeyCache = function(exportTableName) {
file.path(tempdir(), paste0(private$databaseId, "-", Sys.getpid(), "-", exportTableName, ".csv"))
Expand Down Expand Up @@ -134,11 +135,15 @@ ResultExportManager <- R6::R6Class(
#' @param minCellCount Minimum cell count - reccomended that you set with
#' options("ohdsi.minCellCount" = count) in all R projects. Default is 5
#' @param databaseId database identifier - required when exporting according to many specs
#' @param validateTypes Test if row values strictly conform to types - optional, not currently reccomended
#' outside of development
initialize = function(tableSpecification,
exportDir,
minCellCount = getOption("ohdsi.minCellCount", default = 5),
validateTypes = FALSE,
databaseId = NULL) {
self$exportDir <- exportDir
self$validateTypes <- validateTypes
# Check table spec is valid
assertSpecificationColumns(colnames(tableSpecification))
private$tableSpecification <- tableSpecification
Expand Down Expand Up @@ -298,11 +303,12 @@ ResultExportManager <- R6::R6Class(
stop("Table not found in specifications")
}

validRows <- self$checkRowTypes(rows, exportTableName)
if (!all(isTRUE(validRows))) {
stop(paste(validRows[!isTRUE(validRows)], collapse = "\n"))
if (self$validateTypes) {
validRows <- self$checkRowTypes(rows, exportTableName)
if (!all(isTRUE(validRows))) {
stop(paste(validRows[!isTRUE(validRows)], collapse = "\n"))
}
}

# Convert < minCellCount to -minCellCount
rows <- self$getMinColValues(rows, exportTableName)
validPkeys <- self$checkPrimaryKeys(rows, exportTableName, invalidateCache = !append)
Expand Down
6 changes: 5 additions & 1 deletion man/ResultExportManager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bb73794

Please sign in to comment.