Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Fixes
* Right truncation of string data for UDF/XSP/UDM udf_md5 during snapshot execution [229](https://github.com/Teradata/dbt-teradata/issues/229)

* dbt snapshot command leading to syntax error in DB version 20.00 or greater

### Docs

### Under the hood
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

snapshotted_data as (

select snapshot.*,
select td_dbt_snapshot.*,
{{ unique_key_fields(strategy.unique_key) }}

from {{ target_relation }} as snapshot
from {{ target_relation }} as td_dbt_snapshot
where
{% if config.get('dbt_valid_to_current') %}
{# Check for either dbt_valid_to_current OR null, in order to correctly update records with nulls #}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
-- [Teradata Database] [Error 3888] A SELECT for a UNION,INTERSECT or MINUS must reference a table
-- To avoid this error we are are using a workaround [ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1 ] in between those sel statements

{% macro get_expected_sql(rows, column_name_to_data_types, column_name_to_quoted) -%}
{{ adapter.dispatch('get_expected_sql', 'dbt')(rows, column_name_to_data_types, column_name_to_quoted) }}
{% macro get_expected_sql(rows, column_name_to_data_types) -%}
{{ adapter.dispatch('get_expected_sql', 'dbt')(rows, column_name_to_data_types) }}
{%- endmacro %}

{% macro teradata__get_expected_sql(rows, column_name_to_data_types, column_name_to_quoted) %}
{% macro teradata__get_expected_sql(rows, column_name_to_data_types) %}

{%- if (rows | length) == 0 -%}
select * from dbt_internal_unit_test_actual
Expand All @@ -17,7 +17,7 @@
{%- for row in rows -%}
{%- set formatted_row = format_row(row, column_name_to_data_types) -%}
select
{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
{%- endfor %}
{%- if not loop.last %}
from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
Expand Down Expand Up @@ -45,12 +45,11 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}

{%- set column_name_to_data_types = {} -%}
{%- set column_name_to_quoted = {} -%}

{%- for column in columns_in_relation -%}

{#-- This needs to be a case-insensitive comparison --#}
{%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}
{%- do column_name_to_quoted.update({column.name|lower: column.quoted}) -%}
{%- endfor -%}
{%- endif -%}

Expand All @@ -67,7 +66,7 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
{%- set default_row_copy = default_row.copy() -%}
{%- do default_row_copy.update(formatted_row) -%}
select
{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
{%- endfor %}
{%- if not loop.last %}
from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
Expand All @@ -78,7 +77,7 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1

{%- if (rows | length) == 0 -%}
select
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%},{%- endif %}
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%},{%- endif %}
{%- endfor %}
sample 0
{%- endif -%}
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pytest~=7.0
tox~=3.2
pylava~=0.3.0
teradatasql>=20.00.00.10
dbt-adapters>=1.7.2
dbt-adapters>=1.7.2,<2.0
dbt-common>=1.3.0
MarkupSafe==2.0.1
pytest-dotenv
Expand Down