question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Be able to !include external yaml files

See original GitHub issue

Describe the feature

Sometimes its useful to reuse yaml (especially the schema.yml sections relating to docs). In my case, I have tables in different schemas and sometimes I have a view to the same table (except with different permissions). Ultimately though the view is just a select * from table_xyz, so the docs are the same. I don’t want to have to maintain the documentation twice, and would prefer just to link to it.

The quick way to do this would be to allow external file linking as described here (https://stackoverflow.com/questions/528281/how-can-i-include-a-yaml-file-inside-another)

This is transparent to dbt and handled by the yaml loader.

Describe alternatives you’ve considered

Duplicating the documentation

Additional context

Who will this benefit?

Anyone who wants to reuse parts of their yaml files

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
laxjessecommented, Apr 28, 2020

similar but different use case: I was hoping to be able to reference a non-schema.yml yaml file in a model.sql context to take advantage of the fromyaml context method.

I basically have a model that looks like this

{% set my_yml_str -%}
test1:
  - eligibility_start_criteria: some business logic
    eligibility_end_criteria: some more business logic
test2:
  - eligibility_start_criteria: more business logic
    eligibility_end_criteria: moar biz logic
goes on for a while ...
{%- endset %}

{% set my_dict = fromyaml(my_yml_str) %}
select
{% for item, criteria in my_dict.items() %}
  '{{ item }}' as group,
  {{ criteria[0]['eligibility_start_criteria'] }} as eligibility_start_criteria,
  {{ criteria[0]['eligibility_end_criteria'] }} as eligibility_end_criteria
{% endfor %}
from test

and was thinking it would be good to be able to maintain my_yml_str in a separate .yml file rather than in the model itself

3reactions
mingfangcommented, Nov 14, 2022

please reopen

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I include a YAML file inside another?
No, standard YAML does not include any kind of "import" or "include" statement.
Read more >
Including YAML configuration files inside another ...
You can include further files in an included file. Instead of a file name, you can also specify the name of a directory...
Read more >
Be able to !include external yaml files · Issue #1790 · dbt- ...
Sometimes its useful to reuse yaml (especially the schema.yml sections relating to docs). In my case, I have tables in different schemas and ......
Read more >
Referencing YAML from an External File
Referencing YAML from an External File. This is an example for how you can reference an 'external' yaml from a separate file.
Read more >
GitLab CI/CD include examples
You can use include to include external YAML files in your CI/CD jobs. Include a single configuration file. To include a single configuration...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found