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

Add "other" relation to reffable node classes #7645

Merged
merged 4 commits into from
May 17, 2023

Conversation

stu-k
Copy link
Contributor

@stu-k stu-k commented May 16, 2023

resolves #7550

Description

As part of dbt clone #7256, we need to add an additional field to reffable nodes (i.e. ModelNode, SeedNode, SnapshotNode). This field holds a relation to another node that will be used later in the dbt clone project to be exposed in a jinja context to enable the clone materialization. The name state_relation is very general and we do not need to use this name.

This code is taken from an existing draft PR that Jeremy has up.

Checklist

@stu-k stu-k requested review from peterallenwebb and a team May 16, 2023 17:47
@stu-k stu-k requested review from a team as code owners May 16, 2023 17:47
@stu-k stu-k requested review from ChenyuLInx, emmyoop and davidbloss and removed request for a team May 16, 2023 17:47
@cla-bot cla-bot bot added the cla:yes label May 16, 2023
@@ -615,6 +619,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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the PR description, state_relation is a very general name that doesn't explain much of what this field holds. Please feel free to suggest better names for this attribute.

Copy link
Contributor Author

@stu-k stu-k May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe other_relation, target_relation, cross_environment_relation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke with Gerda about this name and she thought it made sense for the context it was in.

@@ -271,16 +271,20 @@ def add_public_node(self, value: str):


@dataclass
class ParsedNodeMandatory(GraphNode, HasRelationMetadata, Replaceable):
class RelationalNode(HasRelationMetadata):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's confusing to use Node in the name here. It's not a Node. These classes are already complicated enough, I don't think it's necessarily a good idea to reuse the existing classes in nodes.py. You're actually reimplementing a Relation class. Do you actually need the separate database/schema/identifier? ("identifier" is what it's actually called in the Relation classes, and makes more sent to me, at least.). I'm not exactly sure how this is going to be used. Would a relation_name (clone_relation_name?) field work?

@stu-k stu-k requested a review from gshank May 17, 2023 15:38
@stu-k stu-k merged commit f6e5582 into main May 17, 2023
@stu-k stu-k deleted the ct-2544/add-other-relation-to-reffable-nodes branch May 17, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2544] Add "other" relation attribute to reffable node classes
2 participants