Skip to content

Commit 871dd9b

Browse files
authored
Merge pull request #101 from ScalefreeCOM/support_md5_binary
Added md5 binary support (Snowflake)
2 parents 4a791f2 + e68cdcd commit 871dd9b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

macros/supporting/hash_default_values.sql

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@
4242

4343
{{ log('hash datatype: ' ~ hash_datatype, false) }}
4444

45-
{%- if hash_function == 'MD5' and hash_datatype == 'STRING' -%}
46-
{%- set hash_alg = 'MD5' -%}
47-
{%- set unknown_key = '!00000000000000000000000000000000' -%}
48-
{%- set error_key = '!ffffffffffffffffffffffffffffffff' -%}
45+
{%- if hash_function == 'MD5' or hash_function == 'MD5_HEX' -%}
46+
{%- if 'VARCHAR' in hash_datatype or 'CHAR' in hash_datatype or 'STRING' in hash_datatype or 'TEXT' in hash_datatype %}
47+
{%- set hash_alg = 'MD5' -%}
48+
{%- set unknown_key = '!00000000000000000000000000000000' -%}
49+
{%- set error_key = '!ffffffffffffffffffffffffffffffff' -%}
50+
{%- elif 'BINARY' in hash_datatype -%}
51+
{%- set hash_alg = 'MD5_BINARY' -%}
52+
{%- set unknown_key = "TO_BINARY('00000000000000000000000000000000')" -%}
53+
{%- set error_key = "TO_BINARY('ffffffffffffffffffffffffffffffff')" -%}
54+
{%- endif -%}
4955
{%- elif hash_function == 'SHA1' or hash_function == 'SHA1_HEX' or hash_function == 'SHA' -%}
5056
{%- if 'VARCHAR' in hash_datatype or 'CHAR' in hash_datatype or 'STRING' in hash_datatype or 'TEXT' in hash_datatype %}
5157
{%- set hash_alg = 'SHA1' -%}
@@ -101,4 +107,4 @@
101107
{{ return(dict_result | tojson ) }}
102108

103109

104-
{%- endmacro -%}
110+
{%- endmacro -%}

0 commit comments

Comments
 (0)