I’m trying to create a unit test (Running with dbt=1.8.3, Registered adapter: trino=1.8.1) for incremental load based on the documentation: Unit tests | dbt Developer Hub
The issue I’m facing is that my input source (from the sources.yaml) is a table that has the same name as the model. In the compiled sql it only creates one cte for the source and the {{ this }}) input and the execution fails. Do you have any suggestions?
table_name.sql
SELECT *
FROM {{ source('test', 'table_name') }} table_name
{% if is_incremental() %}
WHERE table_name.updated_at >= (SELECT updated_at FROM {{ this }})
{% endif %}
unit_test.yaml
unit_tests:
- name: table_name_incremental_mode
model: table_name
overrides:
macros:
# unit test this model in "incremental" mode
is_incremental: true
given:
- input: this
rows:
- { event_id: 1, event_time: 2020-01-01}
- input: source('test', 'table_name')
rows:
- { event_id: 1, event_time: 2020-01-01}
- { event_id: 2, event_time: 2020-01-02}