Skip to content

Commit 3e5df2e

Browse files
committed
passing sqlite and duckdb
1 parent 5e81375 commit 3e5df2e

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

R/runOrphanConcepts.R

+15-20
Original file line numberDiff line numberDiff line change
@@ -386,32 +386,27 @@ runOrphanConcepts <- function(connection,
386386
incremental = TRUE
387387
)
388388

389-
ParallelLogger::logTrace("Dropping temp concept set table")
390-
sql <-
391-
"TRUNCATE TABLE #inst_concept_sets; DROP TABLE #inst_concept_sets;"
392-
DatabaseConnector::renderTranslateExecuteSql(
393-
connection,
394-
sql,
395-
tempEmulationSchema = tempEmulationSchema,
396-
progressBar = FALSE,
397-
reportOverallTime = FALSE
398-
)
389+
# TODO eliminate inst_concept_sets after three analysis complete in executeDiagnostics
390+
# if (tempTableExists(connection, "inst_concept_sets")) {
391+
# ParallelLogger::logTrace("Dropping Unique ConceptSets table")
392+
# sql <-
393+
# "TRUNCATE TABLE #inst_concept_sets; DROP TABLE #inst_concept_sets;"
394+
# DatabaseConnector::renderTranslateExecuteSql(
395+
# connection,
396+
# sql,
397+
# tempEmulationSchema = tempEmulationSchema,
398+
# progressBar = FALSE,
399+
# reportOverallTime = FALSE
400+
# )
401+
# }
399402

400-
if (nrow(subsetOrphans) > 0) {
401-
ParallelLogger::logTrace("Dropping temp concept count table")
402-
if (conceptCountsTableIsTemp) {
403-
countTable <- conceptCountsTable
404-
} else {
405-
countTable <-
406-
paste(conceptCountsDatabaseSchema, conceptCountsTable, sep = ".")
407-
}
408-
403+
if (conceptCountsTableIsTemp) {
409404
sql <- "TRUNCATE TABLE @count_table; DROP TABLE @count_table;"
410405
DatabaseConnector::renderTranslateExecuteSql(
411406
connection,
412407
sql,
413408
tempEmulationSchema = tempEmulationSchema,
414-
count_table = countTable,
409+
count_table = conceptCountsTable,
415410
progressBar = FALSE,
416411
reportOverallTime = FALSE
417412
)

tests/testthat/setup.R

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
library(CohortDiagnostics)
2-
library(testthat)
3-
41
dbmsToTest <- c(
5-
"sqlite"#,
2+
# "sqlite"#,
63
# "duckdb"#,
7-
# "postgresql"#,
4+
"postgresql"#,
85
# "redshift",
96
# "sql server",
107
)

tests/testthat/test-runOrphanConcepts.R

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616

1717
for (nm in names(testServers)) {
18-
nm <- "sqlite"
18+
# nm <- "duckdb"
1919
server <- testServers[[nm]]
2020

2121
# Params
@@ -33,17 +33,18 @@ for (nm in names(testServers)) {
3333
cohortTableNames <- CohortGenerator::getCohortTableNames(cohortTable = server$cohortTable)
3434
cohortDatabaseSchema <- server$cohortDatabaseSchema
3535
cohortTable <- server$cohortTable
36-
incremental <- FALSE
37-
# incremental <- TRUE
36+
# incremental <- FALSE
37+
incremental <- TRUE
3838
conceptIdTable <- "#concept_ids"
39+
recordKeepingFile <- file.path(exportFolder, "record.csv")
3940

4041
# Tests
4142

4243
test_that(paste("test run inclusion statistics output", nm), {
4344
connection <- DatabaseConnector::connect(server$connectionDetails)
44-
exportFolder <- file.path(tempdir(), paste0(nm, "no_concept"))
45-
dir.create(exportFolder)
45+
exportFolder <- file.path(tempdir(), paste0(nm, "_no_concept"))
4646
recordKeepingFile <- file.path(exportFolder, "record.csv")
47+
dir.create(exportFolder)
4748
# CreateConceptcounts table
4849

4950
CohortDiagnostics::createConceptCountsTable(connection = connection,
@@ -125,6 +126,7 @@ for (nm in names(testServers)) {
125126
test_that(paste("test run inclusion statistics output", nm), {
126127
connection <- DatabaseConnector::connect(server$connectionDetails)
127128
exportFolder <- file.path(tempdir(), paste0(nm, "_no_concept"))
129+
recordKeepingFile <- file.path(exportFolder, "record.csv")
128130
dir.create(exportFolder)
129131

130132
# Instantiate Unique ConceptSets
@@ -178,6 +180,6 @@ for (nm in names(testServers)) {
178180
expect_equal(unique(recordKeeping$task), "runOrphanConcepts")
179181
expect_true(all(recordKeeping$cohortId %in% server$cohortDefinitionSet$cohortId))
180182

181-
unlink(exportFolder)
183+
unlink(exportFolder, recursive = TRUE)
182184
})
183185
}

0 commit comments

Comments
 (0)