diff --git a/core/dbt/artifacts/resources/__init__.py b/core/dbt/artifacts/resources/__init__.py index c167544a207..9a8811646cf 100644 --- a/core/dbt/artifacts/resources/__init__.py +++ b/core/dbt/artifacts/resources/__init__.py @@ -29,5 +29,6 @@ Entity, Measure, MeasureAggregationParameters, + NodeRelation, NonAdditiveDimension, ) diff --git a/core/dbt/artifacts/resources/v1/semantic_model.py b/core/dbt/artifacts/resources/v1/semantic_model.py index 53394d02f80..15d406e0715 100644 --- a/core/dbt/artifacts/resources/v1/semantic_model.py +++ b/core/dbt/artifacts/resources/v1/semantic_model.py @@ -21,6 +21,14 @@ class Defaults(dbtClassMixin): agg_time_dimension: Optional[str] = None +@dataclass +class NodeRelation(dbtClassMixin): + alias: str + schema_name: str # TODO: Could this be called simply "schema" so we could reuse StateRelation? + database: Optional[str] = None + relation_name: Optional[str] = None + + # ==================================== # Dimension objects # ==================================== diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 38076f90424..a82c3e43506 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -96,6 +96,7 @@ Measure as MeasureResource, Documentation as DocumentationResource, Macro as MacroResource, + NodeRelation as NodeRelationResource, NodeVersion, Group as GroupResource, GraphResource, @@ -1623,18 +1624,10 @@ class Group(GroupResource, BaseNode): # ==================================== -@dataclass -class NodeRelation(dbtClassMixin): - alias: str - schema_name: str # TODO: Could this be called simply "schema" so we could reuse StateRelation? - database: Optional[str] = None - relation_name: Optional[str] = None - - @dataclass class SemanticModel(GraphNode): model: str - node_relation: Optional[NodeRelation] + node_relation: Optional[NodeRelationResource] description: Optional[str] = None label: Optional[str] = None defaults: Optional[DefaultsResource] = None diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 644009a06cb..66cccfbcac0 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -106,9 +106,8 @@ ManifestNode, ResultNode, ModelNode, - NodeRelation, ) -from dbt.artifacts.resources import NodeVersion +from dbt.artifacts.resources import NodeRelation, NodeVersion from dbt.artifacts.schemas.base import Writable from dbt.exceptions import ( TargetNotFoundError, diff --git a/tests/unit/test_graph_selector_methods.py b/tests/unit/test_graph_selector_methods.py index 9726c4ab2e9..9482fbdfb0d 100644 --- a/tests/unit/test_graph_selector_methods.py +++ b/tests/unit/test_graph_selector_methods.py @@ -17,7 +17,6 @@ MetricTypeParams, MetricInputMeasure, Group, - NodeRelation, SavedQuery, SeedNode, SemanticModel, @@ -31,7 +30,7 @@ UnitTestDefinition, ) from dbt.contracts.graph.manifest import Manifest, ManifestMetadata -from dbt.artifacts.resources import QueryParams +from dbt.artifacts.resources import NodeRelation, QueryParams from dbt.contracts.graph.unparsed import ( ExposureType, Owner, diff --git a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py index 40d993719fd..8a1b21aa1bc 100644 --- a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py +++ b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py @@ -9,7 +9,6 @@ MetricInputMeasure, MetricTimeWindow, MetricTypeParams, - NodeRelation, SavedQuery, SemanticModel, ) @@ -22,6 +21,7 @@ FileSlice, Measure, MeasureAggregationParameters, + NodeRelation, NonAdditiveDimension, SourceFileMetadata, WhereFilter,