Skip to content

Commit

Permalink
fix ModelNodeArgs.fqn (#8364)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9388030)
  • Loading branch information
MichelleArk authored and github-actions[bot] committed Aug 12, 2023
1 parent 8bd5b21 commit 4b12948
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230811-204144.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: fix fqn-selection for external versioned models
time: 2023-08-11T20:41:44.725144-04:00
custom:
Author: michelleark
Issue: "8374"
8 changes: 8 additions & 0 deletions core/dbt/contracts/graph/node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ def unique_id(self) -> str:
unique_id = f"{unique_id}.v{self.version}"

return unique_id

@property
def fqn(self) -> List[str]:
fqn = [self.package_name, self.name]
if self.version:
fqn.append(f"v{self.version}")

return fqn
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def from_args(cls, args: ModelNodeArgs) -> "ModelNode":
name=args.name,
package_name=args.package_name,
unique_id=unique_id,
fqn=[args.package_name, args.name],
fqn=args.fqn,
version=args.version,
latest_version=args.latest_version,
relation_name=args.relation_name,
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_contracts_graph_node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,22 @@ def test_model_node_args_unique_id_with_version(self) -> None:
version="1",
)
assert model_node_args.unique_id == "model.package.name.v1"

def test_model_node_args_fqn(self) -> None:
model_node_args = ModelNodeArgs(
name="name",
package_name="package",
identifier="identifier",
schema="schema",
)
assert model_node_args.fqn == ["package", "name"]

def test_model_node_args_fqn_with_version(self) -> None:
model_node_args = ModelNodeArgs(
name="name",
package_name="package",
identifier="identifier",
schema="schema",
version="1",
)
assert model_node_args.fqn == ["package", "name", "v1"]

0 comments on commit 4b12948

Please sign in to comment.