Skip to content

Commit 64667bb

Browse files
authored
Adding group to model definition (#99)
We have several use cases where we want to make assertions about a model's [`group`](https://docs.getdbt.com/docs/collaborate/govern/model-access#groups); adding that to the model so it is accessible for rules.
1 parent edbfa84 commit 64667bb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/dbt_score/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class Model(HasColumnsMixin):
173173
raw_code: The raw code of the model.
174174
language: The language of the model, e.g. sql.
175175
access: The access level of the model, e.g. public.
176+
group: The group the model is in.
176177
alias: The alias of the model.
177178
patch_path: The yml path of the model, e.g. `package://model_dir/dir/file.yml`.
178179
tags: The list of tags attached to the model.
@@ -196,6 +197,7 @@ class Model(HasColumnsMixin):
196197
raw_code: str
197198
language: str
198199
access: str
200+
group: str
199201
alias: str | None = None
200202
patch_path: str | None = None
201203
tags: list[str] = field(default_factory=list)
@@ -225,6 +227,7 @@ def from_node(
225227
raw_code=node_values["raw_code"],
226228
language=node_values["language"],
227229
access=node_values["access"],
230+
group=node_values["group"],
228231
alias=node_values["alias"],
229232
patch_path=node_values["patch_path"],
230233
tags=node_values["tags"],

tests/resources/manifest.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"tags": [],
3737
"depends_on": {},
3838
"language": "sql",
39-
"access": "protected"
39+
"access": "protected",
40+
"group": null
4041
},
4142
"model.package.model2": {
4243
"resource_type": "model",
@@ -67,7 +68,8 @@
6768
"tags": [],
6869
"depends_on": {},
6970
"language": "sql",
70-
"access": "public"
71+
"access": "public",
72+
"group": "them_over_there"
7173
},
7274
"model.package2.model1": {
7375
"resource_type": "model",
@@ -98,7 +100,8 @@
98100
"tags": [],
99101
"depends_on": {},
100102
"language": "sql",
101-
"access": "public"
103+
"access": "public",
104+
"group": "them_over_there"
102105
},
103106
"test.package.test1": {
104107
"resource_type": "test",

0 commit comments

Comments
 (0)