14 lines
940 B
SQL
14 lines
940 B
SQL
{% macro unique_key_join_on(unique_key, identifier, from_identifier) %}
|
|
{% if unique_key | is_list %}
|
|
{% for key in unique_key %}
|
|
{% set source_unique_key = (identifier ~ ".dbt_unique_key_" ~ loop.index) | trim %}
|
|
{% set target_unique_key = (from_identifier ~ ".dbt_unique_key_" ~ loop.index) | trim %}
|
|
{# Use Oracle-specific NULL-safe equality matching oracle__equals macro #}
|
|
({{ source_unique_key }} = {{ target_unique_key }} OR ({{ source_unique_key }} IS NULL AND {{ target_unique_key }} IS NULL))
|
|
{%- if not loop.last %} and {%- endif %}
|
|
{% endfor %}
|
|
{% else %}
|
|
{# Use Oracle-specific NULL-safe equality for single unique_key as well #}
|
|
({{ identifier }}.dbt_unique_key = {{ from_identifier }}.dbt_unique_key OR ({{ identifier }}.dbt_unique_key IS NULL AND {{ from_identifier }}.dbt_unique_key IS NULL))
|
|
{% endif %}
|
|
{% endmacro %} |