-
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
[macro] [false positives] environment-aware logic in config should not cause resources to always be selected by state:modified #9564
Comments
Historical context on why we've said that this is hard, at least in the past:
We'd need some way to statically extract + save the "unrendered" value of An alternative approach is to let users put macros in their yaml configs, such as:
This would make it easier for us to save If we do go down that route, we might want a different UX — a "snippet"? a "pure macro"? — to make clear that these macros can only be static input-output machines. They can reference vars + env vars + |
Related to #3277 |
Got a similar use case to @graciegoheen mentioned dynamically set my snowflake warehouse based on my environment (assuming from the title as I don't have access). Personally, having a way to specify all of the model-specific config override at the .sql file itself makes it intuitive on the override settings of that particular model. |
This might be a different issue, but it could also be related and the quoted paragraph touches on the generate_x_name-macros which definately are related to my problem. We have a set-up where we override generate_database_name to separate environments and projects into separate databases (it uses target.name from a dynamically generated profiles.yml + database/custom database). While we have the exact same database config across our environments, it seems that only the output from get_database_name is stored in the manifest and therefore marks all our models as modified when comparing dev to prod. The use case here is slim CI. |
Is this your first time submitting a feature request?
Describe the feature
Many folks want to have logic in their dbt project that purposely differs by environment.
For example, let's say I want to materialize a model as a view in dev but as a table in prod.
To accomplish this, I use a macro in my config block:
with the following macro:
When selecting
--select state:modified
and comparing mydev
environment to a manifest fromprod
, this model will ALWAYS be marked as modified. This is because, the materialized config appears different - inprod
it'stable
, indev
it'sview
.Instead, if I've changed nothing about this model OR macro, it shouldn't be marked as modified because the macro logic hasn't changed.
If I've changed the model OR the macro, it should be marked as modified.
Describe alternatives you've considered
A current work-around is to pull the raw jinja out of my macro and put all environment-based logic directly into my
dbt_project.yml
file (can't set configs to output of macros indbt_project.yml
).If instead, I were to configure this model as so:
it would NOT be picked up when selecting
--select state:modified
.But this is cumbersome (reduces DRY code), unexpected, and can lead to an unnecessarily massive
dbt_project.yml
file.Who will this benefit?
Anyone who wants to use
state:modified
and has environment-based logic in their dbt project.See internal use case:
Are you interested in contributing this feature?
No response
Anything else?
Potential solution #6170 (comment)
This is relevant for all resources that can be configured, not just models.
The text was updated successfully, but these errors were encountered: