dbt-selly/macros/cross_db_utils/surrogate_key.sql

26 lines
685 B
MySQL
Raw Normal View History

2022-03-22 04:03:52 +00:00
{# surrogate_key ---------------------------------- #}
{% macro oracle__surrogate_key(field_list) -%}
ora_hash(
{%- for field in field_list %}
{% if not loop.last %}
{{ field }} || '~' ||
{% else %}
{{ field }}
{% endif %}
{%- endfor %}
)
{%- endmacro %}
{% macro clickhouse__surrogate_key(field_list) -%}
assumeNotNull(hex(MD5(
{%- for field in field_list %}
{% if not loop.last %}
toString({{ field }}) || '~' ||
{% else %}
toString({{ field }})
{% endif %}
{%- endfor %}
)))
{%- endmacro %}