Skip to content

Commit

Permalink
Merge pull request #278 from ScalefreeCOM/add-array-and-variant-to-sn…
Browse files Browse the repository at this point in the history
…owflake-ghost-records

Add the datatypes Array and Variant to Snowflake ghost records
  • Loading branch information
tkirschke authored Oct 23, 2024
2 parents d083d23 + 6c822cb commit 30ae0c7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions macros/supporting/ghost_record_per_datatype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,15 @@
{%- endif -%}
{%- elif datatype in ['NUMBER','INT','FLOAT','DECIMAL'] %}{{unknown_value__numeric}} AS {{ alias }}
{%- elif datatype == 'BOOLEAN' %}CAST('FALSE' AS BOOLEAN) AS {{ alias }}
{%- elif datatype in ['ARRAY', 'VARIANT'] %} CAST('{{ unknown_value__STRING }}' as {{ datatype }} ) AS {{ alias }}
{%- else %}NULL AS {{ alias }}
{% endif %}
{%- elif ghost_record_type == 'error' -%}
{%- if datatype in ['TIMESTAMP_NTZ','TIMESTAMP'] %}{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }} AS {{ alias }}
{%- elif datatype == 'DATE'-%} TO_DATE('{{ end_of_all_times_date }}', '{{ date_format }}' ) as {{ alias }}
{%- elif datatype in ['STRING','VARCHAR','TEXT'] %}'{{ error_value__STRING }}' AS {{ alias }}
{%- elif datatype == 'CHAR' %}CAST('{{ error_value_alt__STRING }}' as {{ datatype }} ) as {{ alias }}
{%- elif datatype.upper().startswith('VARCHAR(') or datatype.upper().startswith('CHAR(') -%}
{%- elif datatype.upper().startswith('VARCHAR(') or datatype.upper().startswith('CHAR(') -%}
{%- if col_size is not none -%}
{%- set error_dtype_length = col_size | int -%}
{%- if '(' not in datatype -%}
Expand All @@ -217,8 +218,9 @@
{%- endif -%}
{% elif datatype in ['NUMBER','INT','FLOAT','DECIMAL'] %}{{error_value__numeric}} AS {{ alias }}
{% elif datatype == 'BOOLEAN' %}CAST('FALSE' AS BOOLEAN) AS {{ alias }}
{%- elif datatype in ['ARRAY', 'VARIANT'] %} CAST('{{ error_value__STRING }}' as {{ datatype }} ) AS {{ alias }}
{% else %}NULL AS {{ alias }}
{% endif %}
{% endif %}
{%- else -%}
{%- if execute -%}
{{ exceptions.raise_compiler_error("Invalid Ghost Record Type. Accepted are 'unknown' and 'error'.") }}
Expand Down

0 comments on commit 30ae0c7

Please sign in to comment.