Skip to content

Commit

Permalink
Consider many-to-one relationships from nodes to files
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran Lozano committed Apr 26, 2020
1 parent 278f764 commit 8f45ece
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/dbt/contracts/graph/parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,15 @@ class ParsedNodeDefaults(ParsedNodeMandatory):
build_path: Optional[str] = None

def write_node(self, target_path: str, subdirectory: str, payload: str):
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
else:
# Many-to-one relationship of nodes to files.
path = os.path.join(self.original_file_path, self.path)
full_path = os.path.join(
target_path, subdirectory, self.package_name,
self.original_file_path
target_path, subdirectory, self.package_name, path
)

write_file(full_path, payload)
Expand Down

0 comments on commit 8f45ece

Please sign in to comment.