Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix databricks ghost records for binary datatype #301

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions macros/supporting/ghost_record_per_datatype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,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 @@ -568,7 +568,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 @@ -578,7 +578,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
Loading