Snapshots fail on structure chnages
Closed this issue · 0 comments
Describe the bug
When the structure of an existing snapshot changes, the execution fails. There are two default macros involved that cause the failure. One is get_true_sql
(v1.7.2 only), and the other one is create_columns
.
The default implementation of get_true_sql
delivers the keyword TRUE
, which doesn't exist in Teradata.
The default implementation of create_columns
performs the following alter table:
alter table {{ relation }} add column "{{ column.name }}" {{ column.data_type }};
Causing following error:
[Error 3707] Syntax error, expected something like '(' between the 'column' keyword and the word 'additional_column'.
In Teradata, the alter table should be performed without the column
keyword.
To solve the problem, we overwriten the macros with the following code.
{% macro teradata__get_true_sql() %}
{{ return('1 = 1') }}
{% endmacro %}
{% macro teradata__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
alter table {{ relation }} add "{{ column.name }}" {{ column.data_type }};
{% endcall %}
{% endfor %}
{% endmacro %}
Steps To Reproduce
Create a snapshot and add a new column to the snapshot.
Expected behavior
The new column is added without error.
Screenshots and log output
The output of dbt --version
:
Core:
- installed: 1.8.3
- latest: 1.8.6 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- teradata: 1.8.0 - Up to date!
The operating system you're using:
Windows 11
The output of python --version
:
Python 3.11.3