Skip to content

Instantly share code, notes, and snippets.

View gabriellegall's full-sized avatar

Gabriel LE GALL gabriellegall

View GitHub Profile
@gnilrets
gnilrets / trange_join.sql
Last active May 3, 2025 01:06
dbt Snapshot Join
{% macro trange_join(left_model, row_key_left, right_model, row_key_right, merge_key, series_key, from_at, to_at) %}
-- Assumptions:
-- Within a series key, there can be no overlapping ranges.
-- Overlaping ranges must be resolved prior to using this macro.
-- The row key represents a set of attributes from a model. It is typically a hash of those
-- attributes. The user is expected to join the results of this macro back to the
-- original data to get the full attribute set.