Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Jun 5, 2023
1 parent 7917bd5 commit d0ddb96
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
BaseNode,
ManifestOrPublicNode,
ModelNode,
RelationalNode,
)
from dbt.contracts.graph.unparsed import SourcePatch, NodeVersion, UnparsedVersion
from dbt.contracts.graph.manifest_upgrade import upgrade_manifest_json
Expand Down Expand Up @@ -1133,6 +1134,30 @@ def merge_from_artifact(
sample = list(islice(merged, 5))
fire_event(MergedFromState(num_merged=len(merged), sample=sample))

# Called by CloneTask.defer_to_manifest
def add_from_artifact(
self,
other: "WritableManifest",
) -> None:
"""Update this manifest by *adding* information about each node's location
in the other manifest.
Only non-ephemeral refable nodes are examined.
"""
refables = set(NodeType.refable())
for unique_id, node in other.nodes.items():
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(
other_node.database, other_node.schema, other_node.alias
)
self.nodes[unique_id] = current.replace(state_relation=state_relation)

# Rebuild the flat_graph, which powers the 'graph' context variable,
# now that we've deferred some nodes
self.build_flat_graph()

# Methods that were formerly in ParseResult

def add_macro(self, source_file: SourceFile, macro: Macro):
Expand Down
9 changes: 9 additions & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ def add_macro(self, value: str):
self.macros.append(value)


@dataclass
class RelationalNode(HasRelationMetadata):
alias: str

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


@dataclass
class DependsOn(MacroDependsOn):
nodes: List[str] = field(default_factory=list)
Expand Down

0 comments on commit d0ddb96

Please sign in to comment.