Skip to content
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

Add ability to import other YML files #10694

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

b-per
Copy link
Contributor

@b-per b-per commented Sep 11, 2024

Resolves #9695 (WIP code)

Problem

Today, we don't allow people to reuse "snippets'' of YAML across files. We can use YAML anchors but they are limited to a single file. This lead to non-DRY configuration where changing some configuration might require changing multiple files

Solution

Add the ability to type!include <filepath.yml> to include the YAML of filepath.yml in the current section of the code.

e.g. with a (too) simple example

models:

  dbt_project_evaluator_integration_tests:
    +materialized: ephemeral
  dbt_project_evaluator:
    +schema: !include ./incl.yml

and incl.yml being

test_schema_123

This would work with nested YAML as well.

TODO

The attached code worked on my machine with the example above, but this is really a WIP and not ready to ship.
Pending would be :

  • adding tests
  • fixing mypy issues
  • handling partial parsing - right now, if the content of the included file is changed, if partial parsing is on, the new value will not be reflected

Anyone wanting to handle the above is welcome to take over this PR 😄

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@cla-bot cla-bot bot added the cla:yes label Sep 11, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

1 similar comment
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 50.90909% with 27 lines in your changes missing coverage. Please review.

Project coverage is 89.05%. Comparing base (316ecfc) to head (e2215b4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10694      +/-   ##
==========================================
- Coverage   89.19%   89.05%   -0.14%     
==========================================
  Files         183      183              
  Lines       23466    23518      +52     
==========================================
+ Hits        20930    20944      +14     
- Misses       2536     2574      +38     
Flag Coverage Δ
integration 86.34% <50.90%> (-0.21%) ⬇️
unit 62.02% <47.27%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.02% <47.27%> (-0.04%) ⬇️
Integration Tests 86.34% <50.90%> (-0.21%) ⬇️

@graciegoheen graciegoheen added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add ability to import/include YAML from other files
2 participants