Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression when an exposure references a deprecated model #10915

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241024-104938.yaml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
# 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)

Check warning on line 593 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L593

Added line #L593 was not covered by tests
if not isinstance(child_node, ModelNode):
continue
if node.is_past_deprecation_date:
Expand Down
17 changes: 17 additions & 0 deletions tests/functional/deprecations/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@
email: [email protected]
"""


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: [email protected]
"""

# deprecated test config fixtures
data_tests_yaml = """
models:
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/deprecations/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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):
Expand Down
Loading