Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshots fail on structure chnages #192

Open
rafaelkrysciak opened this issue Sep 4, 2024 · 0 comments · Fixed by #193 · May be fixed by #194
Open

Snapshots fail on structure chnages #192

rafaelkrysciak opened this issue Sep 4, 2024 · 0 comments · Fixed by #193 · May be fixed by #194
Labels
bug Something isn't working

Comments

@rafaelkrysciak
Copy link

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

@rafaelkrysciak rafaelkrysciak added the bug Something isn't working label Sep 4, 2024
@tallamohan tallamohan linked a pull request Sep 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant