Skip to content

Commit

Permalink
Hash implementation for Redshift adapter (#13)
Browse files Browse the repository at this point in the history
* adds hash implementation for redshift adapter

* chore: suppress new macro from docs

---------

Co-authored-by: Ted Conbeer <[email protected]>
  • Loading branch information
owen-dice and tconbeer authored Feb 13, 2023
1 parent 4033d3a commit 511d978
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions macros/utils/docs/helpers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ macros:
- name: bigquery__simple_hash
docs:
show: false
- name: redshift__simple_hash
docs:
show: false
- name: postgres__simple_hash
docs:
show: false
Expand Down
4 changes: 4 additions & 0 deletions macros/utils/simple_hash.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ sha2( ({{ expr }})::varchar, {{ digest_size }})
encode(sha{{ digest_size }} ( ({{ expr }})::varchar::bytea), 'hex')
{%- endmacro -%}

{%- macro redshift__simple_hash(expr, digest_size=256) -%}
sha2( ({{ expr }})::varchar, {{ digest_size }})
{%- endmacro -%}

{%- macro bigquery__simple_hash(expr, digest_size=256) -%}
{{- dbt_privacy.raise_on_bad_digest_size(digest_size, ok_sizes=[256, 512]) -}}
to_hex(sha{{ digest_size }} (cast({{ expr }} as string)))
Expand Down

0 comments on commit 511d978

Please sign in to comment.