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

dbt test supports --resource-type / --exclude-resource-type CLI flags and related environment variables #6126

Closed
wants to merge 14 commits into from
Closed
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion website/docs/reference/global-configs/resource-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

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

Suggested change
The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt clone`, and `dbt list` commands.
The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt clone`, and `dbt list` commands. Starting in Versionless and dbt v1.9, these flags are also supported in the `dbt test` command.


</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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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: build, test, clone, and list.


</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
Expand Down Expand Up @@ -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)
Expand All @@ -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)`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need callouts like "now" - we should:

  • have a callout that this is available in versionless and starting in dbt Core v1.9
  • then document the feature


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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Instead of targeting specific resources, use the `--resource-flag` or `--exclude-resource-type` flags with the `build` or `test` command 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.

I think this is all we need?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Expand Down Expand Up @@ -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>
Loading