Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship test is not triggered #3903

Closed
1 of 5 tasks
leoch20 opened this issue Sep 17, 2021 · 1 comment
Closed
1 of 5 tasks

Relationship test is not triggered #3903

leoch20 opened this issue Sep 17, 2021 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@leoch20
Copy link

leoch20 commented Sep 17, 2021

Describe the bug

The relationship test does not get triggered

Steps To Reproduce

models/child.sql

select 1 as parent_id, 1 as val
union
select 2 as parent_id, 2 as val

models/parent.sql

select 1 as id, 1 as val

models/test.yml

models:
  - name: child
    columns:
      - name: parent_id
        tests:
          - relationships:
              to: ref('parent')
              field: id

  - name: parent
    columns:
      - name: id

Create the models:
dbt run -m parent child

Expected behavior

Running dbt test -m child should error out, but it does not. Although, running dbt test -m parent child does error out.

Screenshots and log output

WARNING: Nothing to do. Try checking your model configs and model specification args

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

installed version: 0.20.1
   latest version: 0.20.2

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation

Plugins:
  - bigquery: 0.20.1
  - snowflake: 0.20.1
  - redshift: 0.20.1
  - postgres: 0.20.1

The operating system you're using:

macOS Big Sur | version 11.4

The output of python --version:

Python 3.8.8
@leoch20 leoch20 added bug Something isn't working triage labels Sep 17, 2021
@jtcohen6
Copy link
Contributor

@leoch20 We made a change in dbt v0.20 around test selection that caught a few folks by surprise (#3496, #3571). I'd recommend you read #3571 (comment) for a quick summary.

To make a long story short, we believe that dbt test -m parent child should absolutely run the relationship test defined between them; but dbt test -m parent or dbt test -m child alone should not presume that you want to include a test with an unselected parent.

The mistake here, for which I take full responsibility, was the subtlety of this change, and the lack of transparency when a familiar command produced a suddenly unfamiliar result. To that end, dbt v0.21 will include better logging around which tests have been excluded because of an unselected parent, as well as an optional --greedy flag that lets you revert to the previous behavior of "greedier" test selection (#3723, #3833).

@jtcohen6 jtcohen6 added duplicate This issue or pull request already exists and removed triage labels Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants