-
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
[Feature] env_var
does not work in an object under the vars
section of dbt_project.yml
#4314
Comments
@joseph-chan-thoughtworks Thanks for opening! The values of I believe this is a duplicate of #3105. We should update the docs here to make clear that Could I ask for a bit more context about the use case you're after? Why are you creating a var to package env var values, rather than just referencing the env vars themselves in your downstream configuration / models / etc? I appreciate the ergonomics of being able to synthesize |
Hey @jtcohen6, one possible use case for this is that packages tend to use variables to control "features". Let's say we use the hubspot package in our project. The way one would disable models in that package is by setting vars that are relevant to that package: # dbt_project.yml
vars:
hubspot_marketing_enabled: false
hubspot_contact_enabled: false
hubspot_sales_enabled: true
hubspot_company_enabled: true
... So to override those many vars, you would have to have some super long string in your run command:
Which is less than ideal. And as of now, the following wont work: Standard variables# dbt_project.yml
vars:
hubspot_marketing_enabled: "{{ var('control_flag_a') }}"
hubspot_contact_enabled: "{{ var('control_flag_a') }}"
hubspot_sales_enabled: "{{ var('control_flag_b') }}"
hubspot_company_enabled: "{{ var('control_flag_b') }}"
...
Environment variables# dbt_project.yml
vars:
hubspot_marketing_enabled: "{{ env_var('control_flag_a') }}"
hubspot_contact_enabled: "{{ env_var('control_flag_a') }}"
hubspot_sales_enabled: "{{ env_var('control_flag_b') }}"
hubspot_company_enabled: "{{ env_var('control_flag_b') }}"
... |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers. |
I would greatly appreciate this feature to exist. |
I would also like this change, if I need to specify a vars per environment, how would I apply this change currently? |
env_var
does not work in an object under the vars
section of dbt_project.yml
That's why I avoid vars (I only use them for setting environment unaware/unrelated things) |
[Preview](https://deploy-preview-3554--docs-getdbt-com.netlify.app/docs/build/project-variables#defining-variables-in-dbt_projectyml) ## What are you changing in this pull request and why? `vars` within `dbt_project.yml` does not support rendering, but it has been requested dbt-labs/dbt-core#3105 and dbt-labs/dbt-core#4314. In the meantime, we want to make it clear within our docs that this isn't supported. See dbt-labs/dbt-core#4314 (comment) for context. ## 🎩 <img width="550" alt="image" src="https://github.com/dbt-labs/docs.getdbt.com/assets/44704949/95e6e65a-028e-4e85-8c56-c4cf12929dc7"> ## Checklist - [x] Review the [Content style guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md) and [About versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version) so my content adheres to these guidelines.
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Is there an existing issue for this?
Current Behavior
This fails due to unexpected "{". However,
Expected Behavior
env_var
within an object should parse correctly as well.Steps To Reproduce
STAGING_DATABASE
andSTAGING_SCHEMA
to your environmentdbt_project.yml
dbt run
or a linter for example sql_fluffRelevant log output
Environment
What database are you using dbt with?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: