# Downstream models still get built even when relationships test fails in dbt build

**URL:** <https://discourse.getdbt.com/t/downstream-models-still-get-built-even-when-relationships-test-fails-in-dbt-build/19360>\
**Category:** Help\
**Tags:** testing, bigquery, dbt-core\
**Created:** [May 13, 2025, 9:24am UTC](https://discourse.getdbt.com/t/downstream-models-still-get-built-even-when-relationships-test-fails-in-dbt-build/19360 "2025-05-13T09:24:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gracia10](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@gracia10](https://discourse.getdbt.com/u/gracia10)\
**Post date:** [May 13, 2025, 9:24am UTC](https://discourse.getdbt.com/t/downstream-models-still-get-built-even-when-relationships-test-fails-in-dbt-build/19360/1 "2025-05-13T09:24:42Z")

</div>

## The problem I’m having

According to the official docs, when a test on an upstream resource fails during `dbt build`, downstream models should be skipped (“Skipping on failures”).  
However, after creating two staging models and defining a `relationships` test between them (which fails), I found that the downstream model still gets built.

## The context of why I’m trying to do this

- I want `relationships` test **failures** in the staging layer to **prevent** downstream models (like intermediate or mart models) from being built.

## What I’ve already tried

- Reduced `threads` to 1 and used `--fail-fast`, but the downstream model still gets built.
- Confirmed that when `not_null` or `unique` tests fail, downstream models **do** get skipped as expected.
- From the logs:
  - When only a `relationships` test exists, the downstream model builds **before** the test runs.
  - But when a `not_null` or `unique` test is also present, tests run **before** the downstream model.

## Some example code or error messages

- stg\_comapny.sql

- stg\_center.sql

- int\_center.sql

- schema.yml

- Run `dbt build --select stg_center+ stg_company+ `

- Add `not_null` test (No data fails the not\_null test, Just look at the order)

---

<div class="post-metadata">

**Author:** ![gracia10](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@gracia10](https://discourse.getdbt.com/u/gracia10)\
**Post date:** [May 13, 2025, 12:42pm UTC](https://discourse.getdbt.com/t/downstream-models-still-get-built-even-when-relationships-test-fails-in-dbt-build/19360/2 "2025-05-13T12:42:47Z")

</div>

After changing `int_center` as shown below, it behaves as expected.  
It seems that relationships tests are only skipped when all downstream models referenced by the test are present.

```auto
-- depends-on: {{ ref('stg_company') }}

WITH 
source AS (
    SELECT
        *
    FROM {{ ref('stg_center') }}
)

SELECT
    *
FROM source

```

```auto
1 of 5 START sql view model temp.stg_center .............................. [RUN]
1 of 5 OK created sql view model temp.stg_center ......................... [CREATE VIEW (0 processed) in 1.14s]
2 of 5 START sql view model temp.stg_company ............................. [RUN]
2 of 5 OK created sql view model temp.stg_company ........................ [CREATE VIEW (0 processed) in 0.64s]
3 of 5 START sql view model temp.int_company ............................. [RUN]
3 of 5 OK created sql view model temp.int_company ........................ [CREATE VIEW (0 processed) in 0.82s]
4 of 5 START test relationships_stg_center_company_id __id__ ref_stg_company_ .... [RUN]
4 of 5 FAIL 1 relationships_stg_center_company_id __id__ ref_stg_company_ ........ [FAIL 1 in 0.93s]
5 of 5 SKIP relation temp.int_center ..................................... [SKIP]

```
