Skip to content

Commit

Permalink
use StateRelation instead of RelationalNode
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed May 16, 2023
1 parent a08eea3 commit 0b25b9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
GraphMemberNode,
ResultNode,
BaseNode,
RelationalNode,
StateRelation,
ManifestOrPublicNode,
)
from dbt.contracts.graph.unparsed import SourcePatch, NodeVersion, UnparsedVersion
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def add_from_artifact(
current = self.nodes.get(unique_id)
if current and (node.resource_type in refables and not node.is_ephemeral):
other_node = other.nodes[unique_id]
state_relation = RelationalNode(
state_relation = StateRelation(
other_node.database, other_node.schema, other_node.alias
)
self.nodes[unique_id] = current.replace(state_relation=state_relation)
Expand Down
17 changes: 12 additions & 5 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ def add_public_node(self, value: str):


@dataclass
class RelationalNode(HasRelationMetadata):
class StateRelation(dbtClassMixin):
database: Optional[str]
schema: str
alias: str

@property
Expand All @@ -280,10 +282,15 @@ def identifier(self):


@dataclass
class ParsedNodeMandatory(GraphNode, RelationalNode, Replaceable):
class ParsedNodeMandatory(GraphNode, HasRelationMetadata, Replaceable):
alias: str
checksum: FileHash
config: NodeConfig = field(default_factory=NodeConfig)

@property
def identifier(self):
return self.alias


# This needs to be in all ManifestNodes and also in SourceDefinition,
# because of "source freshness"
Expand Down Expand Up @@ -619,7 +626,7 @@ class ModelNode(CompiledNode):
constraints: List[ModelLevelConstraint] = field(default_factory=list)
version: Optional[NodeVersion] = None
latest_version: Optional[NodeVersion] = None
state_relation: Optional[RelationalNode] = None
state_relation: Optional[StateRelation] = None

@property
def is_latest_version(self) -> bool:
Expand Down Expand Up @@ -802,7 +809,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[RelationalNode] = None
state_relation: Optional[StateRelation] = None

def same_seeds(self, other: "SeedNode") -> bool:
# for seeds, we check the hashes. If the hashes are different types,
Expand Down Expand Up @@ -1001,7 +1008,7 @@ class IntermediateSnapshotNode(CompiledNode):
class SnapshotNode(CompiledNode):
resource_type: NodeType = field(metadata={"restrict": [NodeType.Snapshot]})
config: SnapshotConfig
state_relation: Optional[RelationalNode] = None
state_relation: Optional[StateRelation] = None


# ====================================
Expand Down

0 comments on commit 0b25b9c

Please sign in to comment.