Skip to content

Commit

Permalink
Add trino md5 macro (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
clausherther authored Feb 19, 2024
1 parent a9c4424 commit 14bea55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ with column_values as (
unpivot_columns as (

{% for column in columns %}
select row_index, '{{ column }}' as column_name, md5({{ column }}) as column_value from column_values
select row_index, '{{ column }}' as column_name, {{ dbt_expectations.md5(column) }} as column_value from column_values
{% if not loop.last %}union all{% endif %}
{% endfor %}
),
Expand Down
16 changes: 16 additions & 0 deletions macros/utils/md5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{%- macro md5(string_value) -%}
{{ return(adapter.dispatch('md5', 'dbt_expectations')(string_value)) }}
{% endmacro %}

{%- macro default__md5(string_value) -%}

{{ dbt.hash(string_value) }}

{%- endmacro -%}


{%- macro trino__md5(string_value) -%}

md5(cast({{ string_value }} as varbinary))

{%- endmacro -%}

0 comments on commit 14bea55

Please sign in to comment.