Chore: Allow duplicate keys in dbt project yaml files#5254
Merged
Conversation
5d30bc5 to
59153ff
Compare
sqlmesh/dbt/common.py
Outdated
Comment on lines
+37
to
+39
| def load_yaml(source: str | Path) -> t.Dict: | ||
| def load_yaml(source: str | Path, allow_duplicate_keys: bool = False) -> t.Dict: | ||
| try: | ||
| return load(source, render_jinja=False) | ||
| return load(source, render_jinja=False, allow_duplicate_keys=allow_duplicate_keys) |
Contributor
There was a problem hiding this comment.
Do we actually need a flag in load_yaml itself here? Is there any call site where we actually don't want to allow duplicates? Curious if we'd match dbt's behavior in those cases.
Contributor
Author
There was a problem hiding this comment.
I just saw this. I made some larger changes for yaml loading to match dbt/pyyaml's behavior of keeping the last occurrence of duplicate keys. I think my changes also address your concerns though.
59153ff to
9998db4
Compare
9998db4 to
f17f73e
Compare
eakmanrq
approved these changes
Aug 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dbt allows duplicate keys, although newer versions emit a deprecation warning. This PR updates yaml loading of dbt projects to also allow duplicate keys and to keep the last value of duplicate keys, matching pyyaml's behavior.