diff --git a/.changes/unreleased/Under the Hood-20230515-152107.yaml b/.changes/unreleased/Under the Hood-20230515-152107.yaml new file mode 100644 index 00000000000..c695c7e945e --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230515-152107.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Add other relation to reffable nodes +time: 2023-05-15T15:21:07.808892-05:00 +custom: + Author: stu-k + Issue: "7550" diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 0c4c2e72dcf..414cf76001e 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -1323,6 +1323,8 @@ def __post_serialize__(self, dct): for unique_id, node in dct["nodes"].items(): if "config_call_dict" in node: del node["config_call_dict"] + if "state_relation" in node: + del node["state_relation"] return dct diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 94d30364a3d..b71e4694ee3 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -269,6 +269,17 @@ def add_public_node(self, value: str): self.public_nodes.append(value) +@dataclass +class StateRelation(dbtClassMixin): + alias: str + database: Optional[str] + schema: str + + @property + def identifier(self): + return self.alias + + @dataclass class ParsedNodeMandatory(GraphNode, HasRelationMetadata, Replaceable): alias: str @@ -557,6 +568,7 @@ class ModelNode(CompiledNode): constraints: List[ModelLevelConstraint] = field(default_factory=list) version: Optional[NodeVersion] = None latest_version: Optional[NodeVersion] = None + state_relation: Optional[StateRelation] = None @property def is_latest_version(self) -> bool: @@ -739,6 +751,7 @@ class SeedNode(ParsedNode): # No SQLDefaults! # and we need the root_path to load the seed later root_path: Optional[str] = None depends_on: MacroDependsOn = field(default_factory=MacroDependsOn) + state_relation: Optional[StateRelation] = None def same_seeds(self, other: "SeedNode") -> bool: # for seeds, we check the hashes. If the hashes are different types, @@ -937,6 +950,7 @@ class IntermediateSnapshotNode(CompiledNode): class SnapshotNode(CompiledNode): resource_type: NodeType = field(metadata={"restrict": [NodeType.Snapshot]}) config: SnapshotConfig + state_relation: Optional[StateRelation] = None # ==================================== diff --git a/test/unit/test_manifest.py b/test/unit/test_manifest.py index ccca812810e..640db1002e5 100644 --- a/test/unit/test_manifest.py +++ b/test/unit/test_manifest.py @@ -93,6 +93,7 @@ "version", "latest_version", "constraints", + "state_relation", } )