Skip to content

Commit

Permalink
Update stats query to address Oracle issue. Expand platform tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed May 1, 2024
1 parent b6e88bd commit 54966a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/CohortStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ getStatsTable <- function(connectionDetails,
}

ParallelLogger::logInfo("- Fetching data from ", table)
sql <- "SELECT {@database_id != ''}?{CAST('@database_id' as VARCHAR(255)) as database_id,} * FROM @cohort_database_schema.@table"
sql <- "SELECT {@database_id != ''}?{CAST('@database_id' as VARCHAR(255)) as database_id,} t.* FROM @cohort_database_schema.@table t"
data <- DatabaseConnector::renderTranslateQuerySql(
sql = sql,
connection = connection,
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ getPlatformConnectionDetails <- function(dbmsPlatform) {
}

return(list(
dbmsPlatform = dbmsPlatform,
connectionDetails = connectionDetails,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
Expand Down
32 changes: 31 additions & 1 deletion tests/testthat/test-dbms-platforms.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,37 @@ testPlatform <- function(dbmsDetails) {
incrementalFolder = file.path(outputFolder, "RecordKeeping", dbmsDetails$connectionDetails$dbms)
)
expect_equal(nrow(cohortsGenerated), nrow(cohortsWithStats))


# Get the cohort counts
cohortCounts <- getCohortCounts(
connectionDetails = dbmsDetails$connectionDetails,
cohortDatabaseSchema = dbmsDetails$cohortDatabaseSchema,
cohortTable = cohortTableNames$cohortTable,
databaseId = dbmsDetails$dbmsPlatform,
cohortDefinitionSet = cohortsWithStats
)
expect_equal(nrow(cohortsGenerated), nrow(cohortCounts))

# Insert the inclusion rule names before exporting the stats tables
insertInclusionRuleNames(
connectionDetails = dbmsDetails$connectionDetails,
cohortDefinitionSet = cohortsWithStats,
cohortDatabaseSchema = dbmsDetails$cohortDatabaseSchema,
cohortInclusionTable = cohortTableNames$cohortInclusionTable
)

exportCohortStatsTables(
connectionDetails = dbmsDetails$connectionDetails,
cohortTableNames = cohortTableNames,
cohortDatabaseSchema = dbmsDetails$cohortDatabaseSchema,
cohortStatisticsFolder = file.path(outputFolder, dbmsDetails$dbmsPlatform),
snakeCaseToCamelCase = FALSE,
fileNamesInSnakeCase = TRUE,
incremental = TRUE,
incrementalFolder = file.path(outputFolder, "RecordKeeping", dbmsDetails$connectionDetails$dbms),
databaseId = dbmsDetails$dbmsPlatform
)

subsetOperations <- list(
createCohortSubset(
cohortIds = 2,
Expand Down

0 comments on commit 54966a8

Please sign in to comment.