-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] Not able to select unit tests via the --resource-type
flag
#10267
Comments
--resource-type
flag
Thanks for reporting this @thijs-nijhuis-shell ! Reprex✅ When using this simple example, these all work for me: dbt list --select "resource_type:unit_test"
dbt list --select "test_type:unit"
dbt list --select "test_name:test_hello_world"
dbt list --select "test_hello_world"
dbt list --resource-type unit_test ✅ And so do all of these (except for the dbt test --select "resource_type:unit_test"
dbt test --select "test_type:unit"
dbt test --select "test_name:test_hello_world"
dbt test --select "test_hello_world"
dbt test --resource-type unit_test ❌ But none of these work -- I get " Nothing to do" for all of them: dbt build --select "resource_type:unit_test"
dbt build --select "test_type:unit"
dbt build --select "test_name:test_hello_world"
dbt build --select "test_hello_world"
dbt build --resource-type unit_test But let's say I add a data test like the following:
models:
- name: hello_world
columns:
- name: hello
tests:
- not_null Most of these commands will work (see below for more explanation on the exceptions): dbt build --select "resource_type:test"
dbt build --select "test_type:data"
dbt build --select "test_name:not_null"
dbt build --select "not_null_hello_world_hello"
dbt build --resource-type test ❌ These two will execute without error, but the included types are not consistent (only data tests for the former but both data tests and unit tests for the latter):
❌ But using
This will include both unit tests and data tests (which seems rational since building a model includes running its unit tests first, materializing the model and then running its data tests): dbt build --select "resource_type:model" |
Hi @dbeatty10 , thanks for elaborate response and testing on the one! |
@thijs-nijhuis-shell I got the same thing as you with ThenHistorically, is presumably because NowBut as-of v1.8, WorkaroundSo I could see us adding dbt test --select "resource_type:unit_test"
dbt test --select "resource_type:test" |
@dbeatty10 , makes sense. Thanks! |
Piggybacking, I noted similar bugs:
The first command picks up unit tests, the second doesn't.
The first command only picks up models, the second picks up models and tests. Tested with dbt 1.8.3 |
@seub to your point, I agree that we should rationalize In the meantime, see below for example workarounds on a sub-command & resource type basis. Example commandsHere are some examples to select only select a specific resource type for a handful of dbt commands (
|
A few different things came up in the course of this thread:
For the first one, the relevant code was introduced in #9273. It looks to me like The second is covered by #10656. I'm not sure the root cause(s) of the third one, and we'll want to create a separate issue for it. |
@thijs-nijhuis good news: this was implemented in #10706, and it will be available in v1.9
|
Is this a new bug in dbt-core?
Current Behavior
We are implementing the new 'unit test' feature; which is great by the way! I have added multiple unit test and tagged them with with 'my_unit_test_tag'.
When I run this, all unit test run and succeed:
dbt test --select tag:my_unit_test_tag
. Using 'dbt build' instead of 'dbt test' also works fine.When I run this though, I get the "Nothing to do. Try checking your model configs and model specification args" message:
dbt build --resource-type unit_test
. I alaso tried with 'resource-types' instead of 'resource-type'; same message.Expected Behavior
According to this page, this command should build all unit test: https://docs.getdbt.com/reference/global-configs/resource-type
Steps To Reproduce
dbt build --resource-type unit_test
. This should run the ut.Relevant log output
No response
Environment
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
I am using dbt-databricks 1.8.1 (so dbt-spark I guess).
The text was updated successfully, but these errors were encountered: