How to skip downstream models following test failures on sources

The problem I’m having:

I would like to configure dbt tests on my sources like this for example and use dbt build to skip downstream (reliant) models using the native skip on failure from dbt build. The skip on failure works great for tests on models and it’s downstream models, but I haven’t been able to consistently reproduce the same effect with tests on sources.

What I’ve already tried

I’ve tried setting up a selector.yml like this and it doesn’t seem to work for fqn:* but i have had some limited success when selecting specific models.

selectors:
  - name: daily_run
    description: "daily dbt run"
    definition:
      union:
        # check freshness + test all sources
        - method: source
          value: '*'

        # select all nodes
        - method: fqn
          value: '*'

        # exclude tagged models
        - exclude:
            - method: tag
              value: exclude

Has anyone been able to successfully implement this type of solution? Would appreciate any insight on this.

hey Jeff, in my experience, if a test on my source data fails dbt build will correctly skip all the downstream models.

can you provide anymore info on why you haven’t been able to “consistently reproduce the same effect with tests on sources”?

dbt build is defined such that if any upstream resource fails (including sources), all the downstream resources are skipped

Note: @Sean Meehan originally posted this reply in Slack. It might not have transferred perfectly.

1 Like

one other thing I just thought of……are you making sure to call on your source in the downstream model via:
from {{ source('jaffle_shop', 'orders') }}
if you don’t do this, dbt won’t know that your model is downstream of the source

Note: @Sean Meehan originally posted this reply in Slack. It might not have transferred perfectly.