-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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] Add ability to import/include YAML from other files #9695
Comments
Thanks @b-per for opening this feature. We really need it to make dbt project be DRY. |
Hi team. Is it something that we'd be keen to merge if I write a PR for it? |
+1 for this feature |
I've been talking about this under the keywords "YAML inheritance" for at least a year. We desperately need it, IMO. I wouldn't be able to contribute to a PR, but I'm 100% on board for anything else to support it. |
|
As a few people have shown interest, I created a draft PR with the code I have so far. It is not ready to be merged, but some people might be willing to take it over from here. |
+1 for this feature I assume this feature is only for more complex, real, data transformations....otherwise everyone would want it??? |
P.S. I've implemented a basic library which supports a lot of what the OP calls out in the "Home Assistant" configuration docs. I've used this for personal projects and it has a few other helper constructors, but at least the code in the library should help with writing custom PyYAML extensions in dbt-common / dbt-core to support similar syntax and behavior during https://github.com/dsillman2000/yaml-extras Note that I use
I took great inspiration from the existing project, pyyaml-include, which I imagine Home Assistant used due to the similar behavior. |
+1 for this feature.
seems to work at first, although when enforcing the contract it looks like the common columns are not detected for the second model. We tried all kind of YAML tricks, but those always result in an error from the loader. Any other suggestion welcome! |
Is this your first time submitting a feature request?
Describe the feature
I wonder if dbt would benefit from providing the ability to include YAML snippets from other files.
Home Assistant (a popular python tool, leveraging YAML for config), provides a few additional YAML constructors (quick overview of constructors).
The most interesting one would be
!include
which allows to define values of keys in YAML from other YAML filesThe implementation of Home Assistant is in this source file.
While we can define some logic in Jinja in some YAML files, we are limited today to defining a single entry at a time (e.g. a string or a bool). With this approach we can also store config for nested fields.
Based on my first observations, this technique wouldn't mess with the current dbt code as the YAML is rendered before we start any "real" dbt parsing.
Describe alternatives you've considered
Copy pasting the same logic in YAML as we do today
Who will this benefit?
dbt_project.yml
from different files, with different code owners in gitAre you interested in contributing this feature?
Yes
Anything else?
I got an early prototype working locally and can share some of the code if we want to implement this feature.
The text was updated successfully, but these errors were encountered: