Hello !
I’ve got 2 tables : my_table_1 and my_table_2 created from a model my_table with a dynamic alias where the alias is set up through the dag. The differences with the two of them are the alias of course but also a column name.
In other words, the my_table_1 schema has the common columns whereas the my_table_2 schema has a column country populated along with the common columns shared with my_table_1.
Creating the tables with the different schema is straight forward but I’m stuck with the my_table.yml and its schema for the testing.
What I’m trying to achieve is to run the my_table.yml using dbt test that would read the my_table_1 schema without the column country but would do it with the my_table_2 schema with the column country
I tried to add a if-statement in the yml file but it doesn’t seem to work (see below).
Do you have any idea how I can achieve that please ?
my_table.yml
models:
- marts:
name: my_table
columns:
{% if alias == "my_table_2" %}
- name: country
tests:
- not_null:
config:
severity: error
{% endif %}
- name: id
tests:
- not_null:
config:
severity: error
- name: name
tests:
- not_null:
config:
severity: error