Skip to content

Commit

Permalink
feat(DiseasystoreBase): Create index on "key_" columns
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusSkytte committed Jul 16, 2024
1 parent 08c5e35 commit dd95d96
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/DiseasystoreBase.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ DiseasystoreBase <- R6::R6Class(


# Commit to DB

# If the table does not exists, we add a index after creation
needs_index <- !SCDB::table_exists(self %.% target_conn, target_table)

# Use update_snapshot to add the data
SCDB::update_snapshot(
.data = ds_updated_feature,
conn = self %.% target_conn,
Expand All @@ -230,6 +235,14 @@ DiseasystoreBase <- R6::R6Class(
logger = logger,
enforce_chronological_order = FALSE
)

if (needs_index && packageVersion("SCDB") > "0.4.0") {
SCDB::create_index(
conn = self %.% target_conn,
db_table = target_table,
columns = purrr::keep(colnames(ds_feature), ~ stringr::str_starts(., "key_|valid_|checksum|from_ts"))
)
}
})

# Release the lock on the table
Expand Down

0 comments on commit dd95d96

Please sign in to comment.