Skip to content

Commit

Permalink
Update ghost_record_per_datatype.sql, fix databricks hash_default_values
Browse files Browse the repository at this point in the history
  • Loading branch information
tkiehn authored Jan 9, 2025
1 parent 8a73818 commit 1570800
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions macros/supporting/ghost_record_per_datatype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@
{%- set error_value__numeric = var('datavault4dbt.error_value__numeric', -2) -%}

{%- set hash = datavault4dbt.hash_method() -%}
{%- set hash_default_values = datavault4dbt.hash_default_values(hash_function=hash) -%}
{%- set unknown_value__HASHTYPE = hash_default_values['unknown_key'] -%}
{%- set hash_default_values = fromjson(datavault4dbt.hash_default_values(hash_function=hash)) -%}
{%- set unknown_value__HASHTYPE = hash_default_values.get('unknown_key') -%}
{%- set error_value__HASHTYPE = hash_default_values['error_key'] -%}

{%- set datatype = datatype | string | upper | trim -%}
Expand All @@ -566,7 +566,7 @@
{%- elif datatype in ['INT', 'SMALLINT', 'TINYINT', 'BIGINT', 'DOUBLE', 'FLOAT'] %} CAST('{{unknown_value__numeric}}' as {{ datatype}}) as {{ alias }}
{%- elif datatype.upper().startswith('DECIMAL') %} CAST('{{unknown_value__numeric}}' as DECIMAL) as {{ alias }}
{%- elif datatype == 'BOOLEAN' %} CAST('FALSE' as BOOLEAN) as {{ alias }}
{%- elif datatype == 'BINARY' %} CAST('{{ unknown_value__HASHTYPE }}') as {{ alias }}
{%- elif datatype == 'BINARY' %} CAST('{{ unknown_value__HASHTYPE }}' as BINARY) as {{ alias }}
{%- else %} CAST(NULL as {{ datatype }}) as {{ alias }}
{% endif %}
{%- elif ghost_record_type == 'error' -%}
Expand All @@ -576,7 +576,7 @@
{%- elif datatype in ['INT', 'SMALLINT', 'TINYINT', 'BIGINT', 'DOUBLE', 'FLOAT'] %} CAST('{{error_value__numeric}}' as {{ datatype}}) as {{ alias }}
{%- elif datatype.upper().startswith('DECIMAL') %} CAST('{{error_value__numeric}}' as DECIMAL) as {{ alias }}
{%- elif datatype == 'BOOLEAN' %} CAST('FALSE' as BOOLEAN) as {{ alias }}
{%- elif datatype == 'BINARY' %} CAST('{{ error_value__HASHTYPE }}') as {{ alias }}
{%- elif datatype == 'BINARY' %} CAST('{{ error_value__HASHTYPE }}' as BINARY) as {{ alias }}
{%- else %} CAST(NULL as {{ datatype }}) as {{ alias }}
{% endif %}
{%- else -%}
Expand Down Expand Up @@ -636,4 +636,4 @@
{%- endif %}
{%- endif -%}

{%- endmacro -%}
{%- endmacro -%}

0 comments on commit 1570800

Please sign in to comment.