Skip to content

Commit f4e7b53

Browse files
committed
groups bugfix
1 parent 48c4ce6 commit f4e7b53

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

integration_tests/tests/test_dbt_artifacts/test_groups.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def test_model_and_groups(dbt_project: DbtProject, tmp_path):
108108
"models": [
109109
{
110110
"name": model_name,
111-
"group": group_name,
111+
"config": {
112+
"group": group_name,
113+
},
112114
"description": "A model assigned to a group for testing",
113115
}
114116
],
@@ -180,12 +182,16 @@ def test_two_groups(dbt_project: DbtProject, tmp_path):
180182
"models": [
181183
{
182184
"name": model_name_1,
183-
"group": group_name_1,
185+
"config": {
186+
"group": group_name_1,
187+
},
184188
"description": "A model assigned to group 1 for testing",
185189
},
186190
{
187191
"name": model_name_2,
188-
"group": group_name_2,
192+
"config": {
193+
"group": group_name_2,
194+
},
189195
"description": "A model assigned to group 2 for testing",
190196
},
191197
],
@@ -262,7 +268,9 @@ def test_test_group_attribute(dbt_project: DbtProject, tmp_path):
262268
"models": [
263269
{
264270
"name": model_name,
265-
"group": group_name,
271+
"config": {
272+
"group": group_name,
273+
},
266274
"description": "A model assigned to a group for testing",
267275
"columns": [{"name": "col", "tests": ["unique"]}],
268276
}
@@ -332,7 +340,9 @@ def test_test_override_group(dbt_project: DbtProject, tmp_path):
332340
"models": [
333341
{
334342
"name": model_name,
335-
"group": test_group,
343+
"config": {
344+
"group": test_group,
345+
},
336346
"description": "A model assigned to a group for testing",
337347
"columns": [
338348
{
@@ -395,7 +405,9 @@ def test_seed_group_attribute(dbt_project: DbtProject, tmp_path):
395405
"seeds": [
396406
{
397407
"name": seed_name,
398-
"group": group_name,
408+
"config": {
409+
"group": group_name,
410+
},
399411
"description": "A seed assigned to a group for testing",
400412
}
401413
],
@@ -465,7 +477,9 @@ def test_snapshot_group_attribute(dbt_project: DbtProject, tmp_path):
465477
"snapshots": [
466478
{
467479
"name": snapshot_name,
468-
"group": group_name,
480+
"config": {
481+
"group": group_name,
482+
},
469483
"description": "A snapshot assigned to a group for testing",
470484
}
471485
],

macros/edr/dbt_artifacts/upload_dbt_tests.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@
133133
{% endif %}
134134
{% endif %}
135135

136+
{% set group_name = config_dict.get("group") or node_dict.get("group") %}
137+
136138
{% set primary_test_model_database = none %}
137139
{% set primary_test_model_schema = none %}
138140
{%- if primary_test_model_id.data is not none -%}
139141
{% set tested_model_node = elementary.get_node(primary_test_model_id.data) %}
140142
{%- if tested_model_node -%}
141143
{% set primary_test_model_database = tested_model_node.get('database') %}
142144
{% set primary_test_model_schema = tested_model_node.get('schema') %}
145+
{% set group_name = group_name or tested_model_node.get('group') %}
143146
{%- endif -%}
144147
{%- endif -%}
145148

@@ -178,7 +181,7 @@
178181
'path': node_dict.get('path'),
179182
'generated_at': elementary.datetime_now_utc_as_string(),
180183
'quality_dimension': unified_meta.get('quality_dimension') or elementary.get_quality_dimension(test_original_name, test_namespace),
181-
'group_name': config_dict.get("group") or node_dict.get("group"),
184+
'group_name': group_name,
182185
}%}
183186
{% do flatten_test_metadata_dict.update({"metadata_hash": elementary.get_artifact_metadata_hash(flatten_test_metadata_dict)}) %}
184187
{{ return(flatten_test_metadata_dict) }}

0 commit comments

Comments
 (0)