Skip to content

Instantly share code, notes, and snippets.

View ljhopkins2's full-sized avatar

Joseph H ljhopkins2

View GitHub Profile
@ljhopkins2
ljhopkins2 / dbt_redshift_drop_vestigial_relations.sql
Last active March 22, 2024 03:41
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 %}