dbtdata-lineage

dbt lineage issue with dbt build and tests


I'm having a problem with dbt lineage... When I run locally this command dbt build --select +model_x it builds 25 models with version 1.7.4 when I updated my dbt to 1.8.3 the dbt build failed and it generated 58 models and tests

So if we ignore the issue that different dbt versions are behaving differently!!!

My main problem is, in this command I ran, I'm only selecting the models and tests related to +model_x the tests which are failing are related to a completely different model !! which should not be run, since I'm selecting specific model lineage. I tried to verify the lineage using dbt docs and the tests which are failing related to models are not included in the lineage, so why am I getting errors for them??? It's driving me crazy ! Anyone has any idea?

Thanks in advance

I tried dbt build --select +model_x I was expecting to build models that model_x depends on, and run the tests of these models and the tests of model_x


Solution

  • I finally found the issue. I will post the answer here in case someone was having similar issue. I was getting error for 3 tests that are generated from one generic test.. which are related to models are not part of the lineage. The generic test code was as following:

    {% test data_latency(model, column_name, unit, num_units) %}
    
    {{ config(severity = 'warn' if target.database == 'DEV_EDW_DB'
                                and model == ref('int_iterable_events')
                            else 'error') }}
    
    select
        max({{ column_name }}) as max_timestamp
    from {{ model }}
    having max_timestamp < date_trunc('{{ unit }}', dateadd('{{ unit }}',-{{ num_units }},current_timestamp()))
    
    {% endtest %}
    

    That ref in the beginning of the test was making the mess.. and breaking the lineage. when I removed it, it was solved.