Closed randypitcherii closed 4 years ago
I know not everyone works with dbt in a way that allows for cleaning up this way, but I think this will be useful for those folks that want a simple way to drop leftover tables without recreating everything they've recently run.
Hi Randy,
Thank you for your contrib!
I wonder if the dbt-snowflake-utils package is the best fit for these macros as they are not solving a Snowflake-specific problem. Keeping a database/schema clean is a universal challenge and these could easily be made cross-database compatible. Perhaps dbt-utils would be a better home for these?
Not a bad idea, Martin. I was probably overly eager to have a place to share some of the macros I've written and overlooked that just because this is built for Snowflake doesn't mean it belongs in a snowflake utils repo.
Thanks for the suggestion!
This PR includes:
cleanup_old_relations
macro that drops any view or table in the target database that has not been modified in a given number of hourscleanup_empty_schemas
macro that drops any schema that is empty, except theINFORMATION_SCHEMA
andPUBLIC
schemas.