Delete intermediate tables after use#89
Merged
RasmusSkytte merged 18 commits intomainfrom Feb 8, 2024
Merged
Conversation
1 task
1 task
17dc692 to
20f4e28
Compare
f5de25e to
4926073
Compare
4926073 to
2ef6de3
Compare
update_snapshot2ef6de3 to
2b5b8fb
Compare
6 tasks
5 tasks
LasseEngboChr
approved these changes
Feb 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fixes #86
Approach
defer_db_cleanupwas added which useswithr::deferto remove the specified table when the function exits.By inserting this function into our functions when we generate new tables, the intermediate tables created will automatically be removed once the function returns.
EDIT: to clarify, it will delete the table once the parent of
defer_db_cleanupexits, not whendefer_db_cleanupexits.A new function
unique_table_name()is added (inspired by dbplyrs internal function of the same name) which gives an easy way to create table names likeSCDB_###for tables.By using this function, we can keep track of the tables that we explicitly need and which should be kept when the function returns (which we can give the "SCDB_" prefix) and those we implicitly create in intermediate computations and should not remain after the function returns (which will get the "dbplyr_" prefix).
A new testing helper
connection_clean_up()is added that is used at the end of tests that use a data base backend.This function looks for the existence of
dbplyr_###tables and gives a warning if they exists. Then it closes the connection to the data base.Known issues
This PR also contains the code being merged inMove functions to separate files #95Once merged, this PR will be rebased and opened.Checklist
NEWS.md