-
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
Allow custom variables inside profiles.yml #2514
Comments
Hey @dalebradman, thanks for the writeup. I don't think we're planning to add anything to
This sounds like a reasonable use case! I want to understand better. Do all of your development users materialize their models in the same database + schema? What value does each person set for I'm wondering if you could create a |
I'm having a use case for this, too. This is what I'm currently using to dynamically select database for my sources (in
I have to set env variable before running dbt and change them before running for a different profile/target, which can easily lead to errors. I'd appreciate if I could define custom variables for each target in
|
@vembloud How many different environments are you running against? Have you considered conditional logic like: sources:
- name: extract
database: "{{ 'extract_prod' if target.name == 'prod' else 'extract_dev' }}"
schema: extract
tables: ... In general, we find a pretty smooth handoff point from "I'm running with a few environments and can write |
@jtcohen6 Thanks for your quick answer. I have considered the conditional logic, but that would require developers to follow the same target naming pattern. We'd probably stick to env variables, then :) |
Fair enough! I'm going to close this issue, since we're not planning to make the code change originally requested (custom target vars in |
@jtcohen6 apologies for the late reply, this skipped my inbox!
Yes all dev users materialise their tables in the same BigQuery project. We've got a like-for-like match between our prod and dev env which is bound to datasets so creating a project per user is out of the question really (for provisioning/maintenance reasons as well). What we did for this is asked each user to set
This has worked very well for us since. |
This is in line with what we do in development, too. I don't totally follow how there can be namespace conflicts if everyone is building into their own dev schema. All the same, I'm glad yo've been able to use |
I dislike this solution since it is not declarative – Ideally, a model can determine its state without dependencies of env vars, at least in the yaml. I would much rather a way of storing variables with a yaml – and in the case of sensitive values, have the keys point to env variables. |
Adding my voice to the others asking for this. Being able to set variables as part of a profile is a much cleaner solution than putting that configuration into conditional expressions or requiring additional setting of environment variables. The choice to not implement this as a capability feels like the wrong decision. |
|
Would be nice to have this, I have extremely long Combined with #4314 it makes the life very hard |
I would also like this change, if I need to specify a vars per environment, how would I apply this change currently? |
Heard! I am sympathetic to the need for better per-env config options. Writing the same conditional expressions (Jinja-in-yaml) doesn't feel very good. Setting environment variables does feel like The Right Solution, but it's a bigger lift for simpler deployments. I still believe this specific proposal would require overloading the profile/target, which is really just the set of necessary credentials & configuration for making & managing a data platform connection. It shouldn't be a means of setting arbitrary conditional configuration, which is what dbt makes possible with But: There's no great way today to tie the value of In the shorter term: We've been spending the last several months revisiting & revamping our configuration story, and there are several ideas proposed in #6207. Some of the options:
|
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. |
Describe the feature
I would like to be able to create and set custom variables inside
~/.dbt/profiles.yml
file and then use these variables within models.Describe alternatives you've considered
.profile
,.bash_rc
,.zshrc
etc. which requires additional command line knowledge. It would also be harder to phase more variables in and deprecate them.with open('~/.dbt/profiles.yml') ...
) and setting variables from there. However this is not currently possibly.Additional context
The goal is to make the initial setup process for installing dbt as simple as possible. A lot of the users will not have command line experience, so it's a big step to get them to update their
~/.dbt/profiles.yml
file. Therefore asking them to also maintain their own environment variables is not ideal and we would be able to provision these variables within our GitHub repo (and deploy efficiently).This would also allow greater flexibility for what we can conditionally do inside
dbt_project.yml
and each of the individual models.Who will this benefit?
The driver behind this is for everyone to set a
DBT_USER_ALIAS
variable that be used as a prefix to table names (insidegenerate_alias_name
) and therefore prevent conflicts from occurring.It will benefit those without that much command line experience, and subsequently administrators who spend time supporting them.
The text was updated successfully, but these errors were encountered: