Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add access to ModelNodeArgs for external node construction
  • Loading branch information
MichelleArk committed Jun 27, 2023
commit 3b7ba3a2c8269afab5876da6ab09f5d102ccaddd
2 changes: 2 additions & 0 deletions core/dbt/contracts/graph/node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional

from dbt.contracts.graph.unparsed import NodeVersion
from dbt.node_types import AccessType


@dataclass
Expand All @@ -16,4 +17,5 @@ class ModelNodeArgs:
version: Optional[NodeVersion] = None
latest_version: Optional[NodeVersion] = None
deprecation_date: Optional[datetime] = None
access: Optional[str] = AccessType.Protected.value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted for a string instead of AccessType to have a simpler interface for the external node construction. Core will still raises an error for an invalid value when it's converted it to an AccessType in ModelNode.from_args

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. We do a similar thing for enums in unparsed classses.

generated_at: datetime = field(default_factory=datetime.utcnow)
1 change: 1 addition & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ def from_args(cls, args: ModelNodeArgs) -> "ModelNode":
alias=args.identifier,
deprecation_date=args.deprecation_date,
checksum=FileHash.from_contents(f"{unique_id},{args.generated_at}"),
access=AccessType(args.access),
original_file_path="",
path="",
)
Expand Down
1 change: 1 addition & 0 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ def build_external_nodes(self) -> List[ModelNodeArgs]:
schema=public_node.schema,
identifier=public_node.identifier,
deprecation_date=public_node.deprecation_date,
access=AccessType.Public,
)
)

Expand Down