From 086d2f60a2f6cea7ea94feb089074c562ed39e86 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 24 Oct 2024 10:43:18 -0600 Subject: [PATCH 1/3] Avoid a KeyError if `child_unique_id` is not found in the dictionary --- core/dbt/parser/manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 493b562bbdc..d5fbef59a6e 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -590,7 +590,7 @@ def check_for_model_deprecations(self): # Get the child_nodes and check for deprecations. child_nodes = self.manifest.child_map[node.unique_id] for child_unique_id in child_nodes: - child_node = self.manifest.nodes[child_unique_id] + child_node = self.manifest.nodes.get(child_unique_id) if not isinstance(child_node, ModelNode): continue if node.is_past_deprecation_date: From 67d8f0a0d8f4ba9f16d3ebf8e25642b5ff89d6c0 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 24 Oct 2024 10:50:05 -0600 Subject: [PATCH 2/3] Changelog entry --- .changes/unreleased/Fixes-20241024-104938.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20241024-104938.yaml diff --git a/.changes/unreleased/Fixes-20241024-104938.yaml b/.changes/unreleased/Fixes-20241024-104938.yaml new file mode 100644 index 00000000000..f47d9feb98b --- /dev/null +++ b/.changes/unreleased/Fixes-20241024-104938.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix bug when referencing deprecated models +time: 2024-10-24T10:49:38.352328-06:00 +custom: + Author: dbeatty10 danlsn + Issue: "10915" From e32ea5c26c34c76ef6b37b867f9177cfa0883a53 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 24 Oct 2024 11:42:15 -0600 Subject: [PATCH 3/3] Functional test when an exposure references a deprecated model --- tests/functional/deprecations/fixtures.py | 17 +++++++++++++++++ .../deprecations/test_deprecations.py | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/functional/deprecations/fixtures.py b/tests/functional/deprecations/fixtures.py index d9ae97603db..85f45d78f47 100644 --- a/tests/functional/deprecations/fixtures.py +++ b/tests/functional/deprecations/fixtures.py @@ -30,6 +30,23 @@ email: something@example.com """ + +deprecated_model_exposure_yaml = """ +version: 2 + +models: + - name: model + deprecation_date: 1999-01-01 00:00:00.00+00:00 + +exposures: + - name: simple_exposure + type: dashboard + depends_on: + - ref('model') + owner: + email: something@example.com +""" + # deprecated test config fixtures data_tests_yaml = """ models: diff --git a/tests/functional/deprecations/test_deprecations.py b/tests/functional/deprecations/test_deprecations.py index 95779338d8a..2cb51935da4 100644 --- a/tests/functional/deprecations/test_deprecations.py +++ b/tests/functional/deprecations/test_deprecations.py @@ -7,6 +7,7 @@ from dbt_common.exceptions import EventCompilationError from tests.functional.deprecations.fixtures import ( bad_name_yaml, + deprecated_model_exposure_yaml, models_trivial__model_sql, ) @@ -99,6 +100,18 @@ def test_package_redirect_fail(self, project): assert expected_msg in exc_str +class TestDeprecatedModelExposure: + @pytest.fixture(scope="class") + def models(self): + return { + "model.sql": models_trivial__model_sql, + "exposure.yml": deprecated_model_exposure_yaml, + } + + def test_exposure_with_deprecated_model(self, project): + run_dbt(["parse"]) + + class TestExposureNameDeprecation: @pytest.fixture(scope="class") def models(self):