Skip to content

Instantly share code, notes, and snippets.

View whrocha's full-sized avatar
👊
Lifelong Learner

Willian "Bill" Rocha whrocha

👊
Lifelong Learner
View GitHub Profile
@whrocha
whrocha / dbt_redshift_drop_vestigial_relations.sql
Created March 22, 2024 03:41 — forked from ljhopkins2/dbt_redshift_drop_vestigial_relations.sql
Looks for db entities that are not in the `dbt` project and produces (and optionally runs) SQL to drop them
{%- macro drop_vestigial_relations(
exclude_schemas=[],
dry_run=False,
raise_on_dry_run=False
) %}
{%- if exclude_schemas is string %}
{%- set exclude_schemas = [exclude_schemas] %}
{%- elif exclude_schemas is not iterable %}
{%- do exceptions.raise_compiler_error('`exclude_schemas` must be a string or a list') %}
{%- endif %}