You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue during a unit test on a model using the create_canonic_table macro. The cookbook.schema and cookbook.name, expected to be fetched from sources.yml, are returning null, causing a compilation error in dbt test' It seems the data from sources.yml isn't correctly passed to the model's macro during testing. Assistance to resolve this issue would be appreciated.
I want to conduct a unit test on this model that employs the macro create_canonic_table as follows:
{%- macro create_canonic_table(source_model, cookbook, add_metadata_cols = True) %}
{% set cookbook_db = cookbook.database %}
{% set cookbook_schema = cookbook.schema %}
{% set cookbook_name = cookbook.name %}
{%- if execute %}
{%- set _cookbook = run_query('select ORIGINAL_NAME,CANONICAL_NAME,CAST_METHOD from ' + cookbook_db + '.' + cookbook_schema + '.' + cookbook_name) %}
...
However, the cookbook.schema and cookbook.name are returning null, which leads to an error when executing 'dbt test':
Compilation Error in unit_test test_pos_canonic_dlt_klarna (models/pos/canonic_dlt/pos_canonic_dlt_klarna.yml) can only concatenate str (not "NoneType") to str 14:44:14 1 of 1 ERROR
The sources.yml file, located in the same directory as the unittest and model files, is as follows:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm encountering an issue during a unit test on a model using the
create_canonic_table
macro. Thecookbook.schema
andcookbook.name
, expected to be fetched from sources.yml, are returning null, causing a compilation error indbt test'
It seems the data fromsources.yml
isn't correctly passed to the model's macro during testing. Assistance to resolve this issue would be appreciated.I want to conduct a unit test on this model that employs the macro
create_canonic_table
as follows:However, the cookbook.schema and cookbook.name are returning null, which leads to an error when executing 'dbt test':
Compilation Error in unit_test test_pos_canonic_dlt_klarna (models/pos/canonic_dlt/pos_canonic_dlt_klarna.yml) can only concatenate str (not "NoneType") to str 14:44:14 1 of 1 ERROR
The sources.yml file, located in the same directory as the unittest and model files, is as follows:
The test is defined as:
Beta Was this translation helpful? Give feedback.
All reactions