Skip to content

Commit 979550f

Browse files
authored
Merge pull request #231 from Teradata/IDE-25313_vs255034
IDE-25313 fix:dbt snapshot syntax error is 20.00.xx version
2 parents a25aa6d + c717b3d commit 979550f

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
### Fixes
66
* Right truncation of string data for UDF/XSP/UDM udf_md5 during snapshot execution [229](https://github.com/Teradata/dbt-teradata/issues/229)
77

8+
* dbt snapshot command leading to syntax error in DB version 20.00 or greater
9+
810
### Docs
911

1012
### Under the hood

dbt/include/teradata/macros/materializations/snapshot/helpers.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525

2626
snapshotted_data as (
2727

28-
select snapshot.*,
28+
select td_dbt_snapshot.*,
2929
{{ unique_key_fields(strategy.unique_key) }}
3030

31-
from {{ target_relation }} as snapshot
31+
from {{ target_relation }} as td_dbt_snapshot
3232
where
3333
{% if config.get('dbt_valid_to_current') %}
3434
{# Check for either dbt_valid_to_current OR null, in order to correctly update records with nulls #}

dbt/include/teradata/macros/materializations/unit/get_fixture_sql.sql

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
-- [Teradata Database] [Error 3888] A SELECT for a UNION,INTERSECT or MINUS must reference a table
44
-- To avoid this error we are are using a workaround [ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1 ] in between those sel statements
55

6-
{% macro get_expected_sql(rows, column_name_to_data_types, column_name_to_quoted) -%}
7-
{{ adapter.dispatch('get_expected_sql', 'dbt')(rows, column_name_to_data_types, column_name_to_quoted) }}
6+
{% macro get_expected_sql(rows, column_name_to_data_types) -%}
7+
{{ adapter.dispatch('get_expected_sql', 'dbt')(rows, column_name_to_data_types) }}
88
{%- endmacro %}
99

10-
{% macro teradata__get_expected_sql(rows, column_name_to_data_types, column_name_to_quoted) %}
10+
{% macro teradata__get_expected_sql(rows, column_name_to_data_types) %}
1111

1212
{%- if (rows | length) == 0 -%}
1313
select * from dbt_internal_unit_test_actual
@@ -17,7 +17,7 @@
1717
{%- for row in rows -%}
1818
{%- set formatted_row = format_row(row, column_name_to_data_types) -%}
1919
select
20-
{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
20+
{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
2121
{%- endfor %}
2222
{%- if not loop.last %}
2323
from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
@@ -45,12 +45,11 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
4545
{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}
4646

4747
{%- set column_name_to_data_types = {} -%}
48-
{%- set column_name_to_quoted = {} -%}
48+
4949
{%- for column in columns_in_relation -%}
5050

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

@@ -67,7 +66,7 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
6766
{%- set default_row_copy = default_row.copy() -%}
6867
{%- do default_row_copy.update(formatted_row) -%}
6968
select
70-
{%- 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 %}
69+
{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {% else %} {{ ' ' }} {%- endif %}
7170
{%- endfor %}
7271
{%- if not loop.last %}
7372
from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
@@ -78,7 +77,7 @@ from SYS_CALENDAR.CALENDAR where day_of_calendar = 1
7877

7978
{%- if (rows | length) == 0 -%}
8079
select
81-
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%},{%- endif %}
80+
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%},{%- endif %}
8281
{%- endfor %}
8382
sample 0
8483
{%- endif -%}

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pytest~=7.0
88
tox~=3.2
99
pylava~=0.3.0
1010
teradatasql>=20.00.00.10
11-
dbt-adapters>=1.7.2
11+
dbt-adapters>=1.7.2,<2.0
1212
dbt-common>=1.3.0
1313
MarkupSafe==2.0.1
1414
pytest-dotenv

0 commit comments

Comments
 (0)