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

[Bug] dbt build : run tests on selected model with tags #11325

Open
2 tasks done
seuf opened this issue Feb 19, 2025 · 0 comments
Open
2 tasks done

[Bug] dbt build : run tests on selected model with tags #11325

seuf opened this issue Feb 19, 2025 · 0 comments
Labels
bug Something isn't working triage

Comments

@seuf
Copy link

seuf commented Feb 19, 2025

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Hi,

I would like to build a dbt model + tests according to the tags I have defined for each tests

For example I have a model:

version: 2

models:
  - name: orders
    config:
      tags:
        - staging
        - production
    columns:
      - name: order_id
        tests:
          - unique:
              tags:
                - production
      - name: customer_id
        tests:
          - not_null:
              tags:
                - staging
                - production

Here I want to run the model + the test "not_null" on the column "customer_id" only when I run the model on the target "staging"

But it seems that tags are herited from the model.

When I run the following command, it runs the model + all the tests (not only the ones with the tag "staging")

dbt build --target staging --select 'orders,tag:staging'
13:16:07  Running with dbt=1.9.0
13:16:09  Registered adapter: bigquery=1.9.0
13:16:17  Found 956 models, 2133 data tests, 797 sources, 186 exposures, 870 macros
13:16:18  
13:16:18  Concurrency: 4 threads (target='staging')
13:16:18  
13:16:20  1 of 4 START sql table model bigquery-project-redacted.dbt.orders  [RUN]
13:16:30  1 of 4 OK created sql table model bigquery-project-redacted.dbt.orders  [CREATE TABLE (8.0 rows, 1.4 GiB processed) in 10.54s]
13:16:30  3 of 4 START test not_null_orders_customer_id . [RUN]
13:16:30  4 of 4 START test unique_orders_order_id ...... [RUN]
13:16:31  3 of 4 PASS not_null_orders_customer_id ....... [PASS in 1.07s]
13:16:31  4 of 4 PASS unique_orders_order_id ............ [PASS in 1.16s]
13:16:31  
13:16:31  Finished running 1 table model, 3 data tests in 0 hours 0 minutes and 13.72 seconds (13.72s).
13:16:31  
13:16:31  Completed with 1 error, 0 partial successes, and 0 warnings:

The test unique_orders_order_id is executed event it don't have the staging tag.

Is there a way to run only the tests with the selected tags on s selected model ?

If I run dbt build -t staging --select "orders tags:staging" it will execute eveything that have the tag staging.

If I remove the tags on on model config, nothing is executed.

Thanks

Expected Behavior

Only the tests having the selected tag:staging are executed.

Steps To Reproduce

Create a model with 2 tags, and tests with only one tag like in the description ⬆

Relevant log output

Environment

- OS: Ubuntu 24.04
- Python: 3.11
- dbt: 1.9.0

Which database adapter are you using with dbt?

bigquery

Additional Context

No response

@seuf seuf added bug Something isn't working triage labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant