Behavior of relationship test wrt Parent model

The problem I’m having

I have two pipelines that culminate in two models each, one acting as the parent (referred) model, the other being the child (referring) . The Child model also has a relationship test defined using ref(‘Parent’)

When I invoke a ‘dbt build +parent’, I notice that the execution fails, and that the relationship test on the Child (relationships_Child_KeyColumn___ref_Parent_KeyColumn) is being run.

Since the child model does not exist yet, nor is it part of the +Parent pipeline, I’m surprised at why the relationship test is being executed as part of the Parent job?

Some example code or error messages

Child yml:

  columns:
    - name: FK_ID
      tests:
      - not_null
      - relationships:
          field: PK_ID
          to: ref('Parent')
1 Like

I am encountering the same issue, has any solution/answer been found?

Facing the same, dbt compares the records of already ran model with unrun model.

I think I ended up with indirect-selection cautious which would ignore the non-run model. It’s been a while since I looked at it.