diff --git a/macros/supporting/ghost_record_per_datatype.sql b/macros/supporting/ghost_record_per_datatype.sql index 03698646..991b212b 100644 --- a/macros/supporting/ghost_record_per_datatype.sql +++ b/macros/supporting/ghost_record_per_datatype.sql @@ -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 -%} @@ -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' -%} @@ -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 -%} @@ -636,4 +636,4 @@ {%- endif %} {%- endif -%} -{%- endmacro -%} \ No newline at end of file +{%- endmacro -%}