Skip to content

Commit

Permalink
fix: change target path for models defined in yml
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuanits committed Feb 19, 2025
1 parent e60b41d commit 182e3bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20250219-224310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Models defined in .yml files have weird paths
time: 2025-02-19T22:43:10.5172941+10:30
custom:
Author: joshuanits
Issue: "11321"
5 changes: 5 additions & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ def get_target_write_path(
if os.path.basename(self.path) == os.path.basename(self.original_file_path):
# One-to-one relationship of nodes to files.
path = self.original_file_path
elif os.path.dirname(self.path) == os.path.basename(self.original_file_path):
parent_dirname = os.path.dirname(self.original_file_path)
dirname = os.path.dirname(self.path).replace(".", "_")
basename = os.path.basename(self.path)
path = os.path.join(parent_dirname, dirname, basename)
else:
# Many-to-one relationship of nodes to files.
path = os.path.join(self.original_file_path, self.path)
Expand Down

0 comments on commit 182e3bd

Please sign in to comment.