-
Notifications
You must be signed in to change notification settings - Fork 982
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
dbt test
supports --resource-type
/ --exclude-resource-type
CLI flags and related environment variables
#6126
Changes from 7 commits
ce39d1f
12e1587
cc335cc
7f9bebf
bbc091e
5b1a6b6
2d29514
c3591be
42efcf8
18d67ca
8935561
a578f4e
76b0405
2fa9413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,8 +4,18 @@ id: "resource-type" | |||||
sidebar: "resource type" | ||||||
--- | ||||||
|
||||||
<VersionBlock lastVersion="1.8"> | ||||||
|
||||||
The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt clone`, and `dbt list` commands. | ||||||
|
||||||
</VersionBlock> | ||||||
|
||||||
<VersionBlock firstVersion="1.9"> | ||||||
|
||||||
The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt test`, `dbt clone`, and `dbt list` commands. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this resolves the comment in #6126 (comment). Namely, as-of v1.9, there are 4 different subcommands that support these flags, and this sentence lists all of them: |
||||||
|
||||||
</VersionBlock> | ||||||
|
||||||
This means the flags enable you to specify which types of resources to include or exclude when running the commands, instead of targeting specific resources. | ||||||
|
||||||
:::tip Note | ||||||
|
@@ -42,7 +52,7 @@ The available resource types are: | |||||
|
||||||
</VersionBlock> | ||||||
|
||||||
<VersionBlock firstVersion="1.8"> | ||||||
<VersionBlock firstVersion="1.8" lastVersion="1.8"> | ||||||
dbeatty10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
- [`analysis`](/docs/build/analyses) | ||||||
- [`exposure`](/docs/build/exposures) | ||||||
|
@@ -58,6 +68,47 @@ The available resource types are: | |||||
|
||||||
</VersionBlock> | ||||||
|
||||||
<VersionBlock firstVersion="1.9"> | ||||||
|
||||||
- [`analysis`](/docs/build/analyses) | ||||||
- [`exposure`](/docs/build/exposures) | ||||||
- [`metric`](/docs/build/build-metrics-intro) | ||||||
- [`model`](/docs/build/models) | ||||||
- [`saved_query`](/docs/build/saved-queries) | ||||||
- [`seed`](/docs/build/seeds) | ||||||
- [`semantic_model`](/docs/build/semantic-models) | ||||||
- [`snapshot`](/docs/build/snapshots) | ||||||
- [`source`](/docs/build/sources) | ||||||
- [`test`](/docs/build/data-tests) | ||||||
- [`unit_test`](/docs/build/unit-tests) | ||||||
dbeatty10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
dbt `test` now enables passing values such as `unit_tests`, `tests`, and more in the `--resource-type` and `--exclude-resource-type` for CLI flags (or in the environment variables `DBT_RESOURCE_TYPES` and `DBT_EXCLUDE_RESOURCE_TYPES)`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need callouts like "now" - we should:
|
||||||
|
||||||
The following are some examples of how dbt `test` enables passing values: | ||||||
dbeatty10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
<Expandable alt_header="CLI flag"> | ||||||
|
||||||
``` | ||||||
dbt `test` --resource-type unit_test | ||||||
dbt `test` --exclude-resource-type unit_test | ||||||
|
||||||
``` | ||||||
|
||||||
</Expandable> | ||||||
|
||||||
<Expandable alt_header="Environment variables"> | ||||||
|
||||||
``` | ||||||
|
||||||
`DBT_RESOURCE_TYPES`=`unit_test` dbt `test` | ||||||
`DBT_EXCLUDE_RESOURCE_TYPES`=`unit_test` dbt `test` | ||||||
|
||||||
``` | ||||||
|
||||||
</Expandable> | ||||||
|
||||||
</VersionBlock> | ||||||
|
||||||
dbeatty10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
## Example | ||||||
|
||||||
Instead of targeting specific resources, use the `--resource-flag` or `--exclude-resource-type` flags to target all resources of a certain type: `dbt build --resource-type RESOURCE_TYPE` replacing `RESOURCE_TYPE` with the resource type you want to include. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this is all we need? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See https://github.com/dbt-labs/docs.getdbt.com/pull/6126/files#r1782100963 which I believe accomplishes this same thing. |
||||||
|
@@ -109,3 +160,27 @@ Instead of targeting specific resources, use the `--resource-flag` or `--exclude | |||||
</File> | ||||||
|
||||||
</VersionBlock> | ||||||
|
||||||
<VersionBlock firstVersion="1.9"> | ||||||
|
||||||
- In this example, use the following command to exclude _all_ unit tests when running tests. Note that the `--exclude-resource-type` flag is only available in dbt version 1.8 and higher: | ||||||
dbeatty10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
<File name='Usage'> | ||||||
|
||||||
```text | ||||||
dbt test --exclude-resource-type unit_test | ||||||
``` | ||||||
|
||||||
</File> | ||||||
|
||||||
- In this example, use the following command to include all data tests when running tests: | ||||||
|
||||||
<File name='Usage'> | ||||||
|
||||||
```text | ||||||
dbt test --resource-type test | ||||||
``` | ||||||
|
||||||
</File> | ||||||
|
||||||
</VersionBlock> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non blocker but thought it might be helpful for 1.8 and lower users to know that newer versions/versionless supports dbt test