Skip to content

Instantly share code, notes, and snippets.

View giuseppegrieco's full-sized avatar
🇮🇹

Giuseppe Grieco giuseppegrieco

🇮🇹
View GitHub Profile
@giuseppegrieco
giuseppegrieco / scd_type_2.sql
Created February 11, 2025 01:32
DBT: Jinja macro to generate SQL for managing SCD Type 2, supporting incremental loads and handling out-of-order data.
{% macro scd_type_2(
target_model,
source_model,
primary_key,
order_by,
load_datetime,
columns,
is_deleted=''
) %}
{# Dynamically creates the sql code to select all the columns #}