From e98e3a75b380257d3f8e01c7f9216bc529ecc2ac Mon Sep 17 00:00:00 2001 From: Myles Hollowed Date: Fri, 18 Oct 2024 14:51:32 -0700 Subject: [PATCH 1/4] Fix: Stop overwriting absolute paths --- core/dbt/contracts/graph/nodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 2d9ff77b385..196d902e59c 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -251,7 +251,7 @@ def get_target_write_path( # This is called for both the "compiled" subdirectory of "target" and the "run" subdirectory 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 + path = self.path else: # Many-to-one relationship of nodes to files. path = os.path.join(self.original_file_path, self.path) From 2b18d70c7c5b54a8aefd7aebfc6ac5276898618b Mon Sep 17 00:00:00 2001 From: Myles Hollowed Date: Fri, 18 Oct 2024 15:03:08 -0700 Subject: [PATCH 2/4] changie new --- .../unreleased/Fixes-20241018-150256.yaml | 6 + index.html | 250 ++++++++++++++++++ 2 files changed, 256 insertions(+) create mode 100644 .changes/unreleased/Fixes-20241018-150256.yaml create mode 100644 index.html diff --git a/.changes/unreleased/Fixes-20241018-150256.yaml b/.changes/unreleased/Fixes-20241018-150256.yaml new file mode 100644 index 00000000000..bf830ea40c0 --- /dev/null +++ b/.changes/unreleased/Fixes-20241018-150256.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Prevent dbt compile from overwriting files that are passed in as absolute paths +time: 2024-10-18T15:02:56.289808-07:00 +custom: + Author: Myles1 + Issue: "10886" diff --git a/index.html b/index.html new file mode 100644 index 00000000000..9be6f0f2b7f --- /dev/null +++ b/index.html @@ -0,0 +1,250 @@ + + + + + + + dbt Docs + + + + + + + + + + + + + + + +
+ icons + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + From dc370bfc8f51fadee1c938cc20af77c26934788c Mon Sep 17 00:00:00 2001 From: Myles Hollowed Date: Tue, 22 Oct 2024 20:11:07 -0700 Subject: [PATCH 3/4] remove extra file --- index.html | 250 ----------------------------------------------------- 1 file changed, 250 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index 9be6f0f2b7f..00000000000 --- a/index.html +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - dbt Docs - - - - - - - - - - - - - - - -
- icons - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - From 9ae8aae0d92f312874f2f73b9a9c09e4f6560379 Mon Sep 17 00:00:00 2001 From: Myles Hollowed Date: Tue, 22 Oct 2024 20:25:56 -0700 Subject: [PATCH 4/4] add regression test for overwriting absolute paths --- .../adapter/simple_seed/test_seed.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/functional/adapter/simple_seed/test_seed.py b/tests/functional/adapter/simple_seed/test_seed.py index 536ed7ad017..18c25713ebf 100644 --- a/tests/functional/adapter/simple_seed/test_seed.py +++ b/tests/functional/adapter/simple_seed/test_seed.py @@ -386,3 +386,27 @@ def test_empty_seeds(self, project): class TestEmptySeed(BaseTestEmptySeed): pass + + +class TestAbsoluteSeedPaths: + """ + This is a regression test for issue #10886. + We're ensuring that dbt will not overwrite files that are passed in as asbolute paths in dbt_project.yml + """ + + @pytest.fixture(scope="class") + def project_config_update(self, project_root): + # Assign an absolute path to seed-paths + return { + "seed-paths": [str(Path(project_root) / "seeds")], + } + + @pytest.fixture(scope="class") + def seeds(self): + return {"my_seed.csv": seed__with_dots_csv} + + def test_absolute_seeds_paths(self, project): + results = run_dbt(["seed"]) + assert len(results) == 1 + # Should not fail due to file being overwritten + results = run_dbt(["seed"])