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

Anther Fix for Semantic model same content #9561

Merged
merged 2 commits into from
Feb 13, 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-20240212-154728.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix Semantic Model Compare node relations
time: 2024-02-12T15:47:28.752107-08:00
custom:
Author: ChenyuLInx
Issue: "9548"
4 changes: 0 additions & 4 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,6 @@ def depends_on_macros(self):
def same_model(self, old: "SemanticModel") -> bool:
return self.model == old.model

def same_node_relation(self, old: "SemanticModel") -> bool:
return self.node_relation == old.node_relation

def same_description(self, old: "SemanticModel") -> bool:
return self.description == old.description

Expand Down Expand Up @@ -1562,7 +1559,6 @@ def same_contents(self, old: Optional["SemanticModel"]) -> bool:

return (
self.same_model(old)
and self.same_node_relation(old)
and self.same_description(old)
and self.same_defaults(old)
and self.same_entities(old)
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/test_semantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dbt.artifacts.resources import Dimension, Entity, Measure, Defaults
from dbt.contracts.graph.nodes import SemanticModel
from dbt.artifacts.resources.v1.semantic_model import NodeRelation
from dbt.node_types import NodeType
from dbt_semantic_interfaces.references import MeasureReference
from dbt_semantic_interfaces.type_enums import AggregationType, DimensionType, EntityType
Expand Down Expand Up @@ -41,7 +42,9 @@ def default_semantic_model(
dimensions=dimensions,
entities=entities,
measures=measures,
node_relation=None,
node_relation=NodeRelation(
alias="test_alias", schema_name="test_schema", database="test_database"
),
)


Expand Down Expand Up @@ -92,3 +95,12 @@ def test_semantic_model_same_contents_update_model(default_semantic_model: Seman
default_semantic_model_copy.model = "ref('test_another_model')"

assert not default_semantic_model.same_contents(default_semantic_model_copy)


def test_semantic_model_same_contents_different_node_relation(
default_semantic_model: SemanticModel,
):
default_semantic_model_copy = deepcopy(default_semantic_model)
default_semantic_model_copy.node_relation.alias = "test_another_alias"
# Relation should not be consided in same_contents
assert default_semantic_model.same_contents(default_semantic_model_copy)
Loading