-
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
[CT-3467] add environment variable / flag to exclude certain resource types #9237
Comments
This makes sense to add a method to configure this environment-wide 'cause always needing to remember to add OptionsIt seems like there are two main options for environment variable(s):
ComparisonBoth options would allow for many different test types. The former would only need a single environment variable and the latter would need to add a new environment variable along with each new test type. Similarly, both options could also be included in UserConfig (if we choose). The latter option would be a bit easier to flip a single type on/off with either an environment variable or a CLI flag. |
Option 1:
Option 2:
Option 3:
Note: If you explicitly passed ^^ is this actually possible? Our thoughts:
HYPOTHESIS -> We think it's likely that there will never be more than 5 test types, maybe there's only 2 test types forever. Thus, we think option 3 is best, and options 1 & 2 are probably over-engineered given we're not going to have tons of test types. |
Setting it in an environment variable is inconsistent from how we do this for other aspects. Historically we have set it in all 3. |
As discussed with @gshank and @dbeatty10.... For consistency, we should have this functionality able to be set in all 3 places: env var, project flags, and CLI flag. |
Similar to the include_saved_query flag dbt-core/core/dbt/cli/params.py Line 409 in c12f6fb
Alternatively we could add a new environment variable for |
Proposed new acceptance criteria to expand this solution to all resource types you may want to exclude from certain environments
This will allow folks to configure:
|
Would be great to add docs here on best practices for what to set this environment variable to (for ci, prod, etc.) |
After various conversations, we decided that it didn't make a lot of sense to have this be settable in project flags, since it's really command specific, not project specific. So we're going to implement env vars and cli params. This applies to three commands: build, list, and clone. |
Does this not apply for run or test? |
No. The only commands that use this are those three. |
I guess you could change that... but that would be a different ticket, I think. |
Hello! How do you actually achieve this:
we also want to exclude them but couldn't figure out how other than maybe adding |
How do you use it so it so it applies it only when target == prod? It's the exclusion depending on the target that I couldn't figure out. |
You can set the environment variable equal to something different in each of your environments. Here's some docs on how this works in dbt Cloud. |
In our case the environment doesn't change, only the target. So it'll go in the line of setting the exclude resource type variable depending on the target using jinja in the dbt_project.yml. |
graciegoheen commented on Mar 12:
#10656 is the ticket that adds this for |
Is this your first time submitting a feature request?
Describe the feature
We expect folks to want to set environment defaults for whether or not unit tests should be included in
dbt build
/dbt test
:Folks have a similar need to exclude other resource types from certain environments ("don't run my snapshots in dev", etc.).
In order to support this exclusion for all resource types...
Acceptance Criteria (updated from discussion below)
Create a new flag ->
DBT_EXCLUDE_RESOURCE_TYPE
/--exclude-resource-type
/ etc.--select
and--exclude
)--exclude-resource-type
is mutually exclusive with--resource-type
Related issue -> [CT-2169] [Bug] All global configs should also be settable in ProjectFlags #7036
Ideally, we'd also expand
--resource-type
to also be an "include resource types" environment variable, flag, etc (but that can be out of scope of this issue if needed)Describe alternatives you've considered
Alternative 1 -> Always remember to specify
--select test_type:...
Alternative 2 -> Setting enabled equal to an environment variable for all unit tests:
DBT_INCLUDE_UNIT_TESTS = false
:(The text was updated successfully, but these errors were encountered: