-
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-369] [Feature] Use variables declared in dbt_project.yml file in the file #4873
Comments
It would make a lot of sense to be able to separate out the variables. I could see doing this in two different ways: moving the vars into their own file or pulling the vars out of the dbt_project file first and using them to process the rest of the file. |
Having the vars in a separate file as one option could make life easier for some devops people as they could move a project around between environments and instead of modifying the vars in the project file, they could just swap different vars files in different environments and leave everything else untouched. |
Looking forward to have something like this as well. Thanks for the initiative @solomonshorser |
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. |
So will this feature be available in the future? |
Upvoting this as I am also running into this issue |
Not sure if it's been mentioned and albeit redundant, you could look into the vars:
special_schema: "my_special_schema"
models:
my_staging_models:
staging:
+materialized: view
common:
+enabled: true
+schema: "{{ var('special_schema', 'my_special_schema') }}" |
I'm trying to set a config for metadata and reference it like below
But am also running into the issue outlined above |
Same here. It'd be awesome to have vars defined in |
Reopening for now. No update on priority or timeline; I just know this is a small pain felt by many. |
Are there any updates on this ticket? Is there any chance that this is going to be considered anytime soon? |
+1 on this feature request. I'm hitting the same constraint when trying to leverage vars in yaml config within
|
Would love this feature! |
If variables are usable in dbt_project.yml then I would want a means to be able to externally access values after interpolation. ie, I can go into technical details if wanted but simply, I have some library code that wants to know the location of the dbt artifacts. For production it is easy enough to parse/compile the dbt project and put the artifacts in a known/static location during the (CI) build process for the library code to find. During development, the library code will parse/compile the project at startup to ensure the artifacts are fresh. The complication is that the dbt target path is configurable, so now the library code needs to know where the target path is. We can enforce a given target path when running dbt, but what about other tooling? Maybe the developer has changed the A simple solution is to read and parse the dbt_project.yml file. So now I'm no longer sure that I want variables to be used in the dbt_project.yml file 🤔, (but I still would like to be able to use variables in sub-section configs like Possible solutions exist to allow the use of variables in the dbt_project.yml file, and I'm sure that one day this will happen. When it does I will definitely want a means for external tooling to be able to know information about the dbt project without having to handle parsing. |
This should be easily doable/supported if we can get #2955 to be implemented first, because we could define the variables outside of Also note that variables currently are available in
But ideally, we can get that changed to:
|
@GKTheOne: You could just require the devs to implement a macro which returns the data you need in JSON format, and run it with
And dbt already has a nice Unfortunately Here's a simple example which outputs the value of a variable:
|
Is there an existing feature request for this?
Describe the Feature
When I declare a variable in a dbt_project file, I sometimes need to use it in the same file. For example:
special_schema
is declared in the project-level vars because I need it in several places. I also need to specify this schema as the schema for some models. Currently when I do the above, I get an error:Describe alternatives you've considered
Currently, I am adding a config block to every model to specify the schema, and that works, but with many models, it gets very repetitive. It would be nice to specify the schema once (using a variable), in the project file, and not have to do it again.
I suppose I could also include
--vars "my_special_schema: some_schema"
when running DBT, but for ease of use by others, I'd prefer to use thevars:
block in the project file. We have many variables, and there are a few more I'd like to use in this way. Passing them all from the CLI makes for messier scripts.Who will this benefit?
Everyone who wants to make use of variables in the project file, for variables that are declared in the project file.
Are you interested in contributing this feature?
Yes, but I'm not sure I have the necessary skills or time.
Anything else?
No response
The text was updated successfully, but these errors were encountered: