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

Conversation

nataliefiann
Copy link
Contributor

@nataliefiann nataliefiann commented Sep 24, 2024

Preview

Resolves #6101

What are you changing in this pull request and why?

Beginning in dbt-core v1.9, it is possible to use the --resource-type and --exclude-resource-type CLI flags (and related env vars) with the dbt test command.

Checklist

@nataliefiann nataliefiann requested a review from a team as a code owner September 24, 2024 13:05
Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview Oct 1, 2024 1:27pm

@github-actions github-actions bot added content Improvements or additions to content size: small This change will take 1 to 2 days to address labels Sep 24, 2024
nataliefiann and others added 3 commits September 24, 2024 14:52
Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com>
Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com>
Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com>
Copy link
Collaborator

@graciegoheen graciegoheen left a comment

Choose a reason for hiding this comment

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

Thanks for opening. I think we can take a simpler approach to the docs changes here. We already have an "Example" section on this page. We should just expand that to mention you can also use this with the dbt test command (instead of just dbt build). Maybe we have examples of using this with both dbt build and dbt test in that section.

website/docs/reference/global-configs/resource-type.md Outdated Show resolved Hide resolved
- [`test`](/docs/build/data-tests)
- [`unit_test`](/docs/build/unit-tests)

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

website/docs/reference/global-configs/resource-type.md Outdated Show resolved Hide resolved
</Expandable>

</VersionBlock>

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

@graciegoheen graciegoheen changed the title dbt test now enables passing values you can now use --resource-type and --exclude-resource-type (CLI flags and env vars) with dbt test command Sep 30, 2024
@github-actions github-actions bot added size: medium This change will take up to a week to address and removed size: small This change will take 1 to 2 days to address labels Oct 1, 2024
@github-actions github-actions bot added size: small This change will take 1 to 2 days to address and removed size: medium This change will take up to a week to address labels Oct 1, 2024
@dbeatty10 dbeatty10 changed the title you can now use --resource-type and --exclude-resource-type (CLI flags and env vars) with dbt test command dbt test supports --resource-type / --exclude-resource-type CLI flags and related environment variables Oct 1, 2024

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

@dbeatty10 dbeatty10 requested a review from graciegoheen October 1, 2024 04:52
@@ -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.

Copy link
Contributor

@mirnawong1 mirnawong1 left a comment

Choose a reason for hiding this comment

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

lgtm!

@nataliefiann
Copy link
Contributor Author

Closed off as Core project has been paused

@mirnawong1
Copy link
Contributor

reopening bc i believe @dbeatty10 is repurposing this pr to make the necessary updates for v1.9

@mirnawong1 mirnawong1 reopened this Oct 1, 2024
@dbeatty10
Copy link
Contributor

Moved to #6192

@dbeatty10 dbeatty10 closed this Oct 1, 2024
dbeatty10 added a commit that referenced this pull request Oct 1, 2024
… flags and related environment variables (#6192)

[Preview](https://docs-getdbt-com-git-dbeatty-6101-docs-dbt-labs.vercel.app/reference/global-configs/resource-type)

Resolves #6101
Originally #6126

## What are you changing in this pull request and why?

Beginning in dbt-core v1.9, it is possible to use the `--resource-type`
and `--exclude-resource-type` CLI flags (and related env vars) with the
`dbt test` command.

## Checklist
- [x] I have reviewed the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [x] The topic I'm writing about is for specific dbt version(s) and I
have versioned it according to the [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and/or [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content)
guidelines.
- [x] Add a note to the prerelease version [Migration
Guide](https://github.com/dbt-labs/docs.getdbt.com/tree/current/website/docs/docs/dbt-versions/core-upgrade)

---------

Co-authored-by: Natalie Fiann <Natalie.Fiann@dbtlabs.com>
Co-authored-by: nataliefiann <120089939+nataliefiann@users.noreply.github.com>
Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com>
Co-authored-by: Mirna Wong <89008547+mirnawong1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content size: small This change will take 1 to 2 days to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] Enable --resource-type and --exclude-resource-type CLI flags and environment variables for dbt test
5 participants