diff --git a/.changes/unreleased/Fixes-20241113-171516.yaml b/.changes/unreleased/Fixes-20241113-171516.yaml new file mode 100644 index 00000000000..9c2f710dbcc --- /dev/null +++ b/.changes/unreleased/Fixes-20241113-171516.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Validate manifest has group_map during group_lookup init +time: 2024-11-13T17:15:16.176082Z +custom: + Author: aranke + Issue: "10988" diff --git a/core/dbt/task/group_lookup.py b/core/dbt/task/group_lookup.py index c02ed26107c..40f21cbe511 100644 --- a/core/dbt/task/group_lookup.py +++ b/core/dbt/task/group_lookup.py @@ -11,6 +11,12 @@ def init(manifest: Optional[Manifest], selected_ids: AbstractSet[str]) -> None: if not manifest: return + if not manifest.groups: + return + + if not hasattr(manifest, "group_map"): + manifest.build_group_map() + _every_group_name_to_group_map = {v.name: v for v in manifest.groups.values()} for group_name, node_ids in manifest.group_map.items(): diff --git a/tests/functional/logging/test_logging.py b/tests/functional/logging/test_logging.py index 9de46a84a95..9c8ed78a11f 100644 --- a/tests/functional/logging/test_logging.py +++ b/tests/functional/logging/test_logging.py @@ -277,3 +277,15 @@ def test_node_info_on_results(self, project, logs_dir): run_result_warning_count += 1 assert run_result_warning_count == 1 + + +class TestRunResultNoGroup: + @pytest.fixture(scope="class") + def models(self): + return { + "my_model.sql": "select 1 as id", + } + + def test_node_info_on_results(self, project, logs_dir): + results = run_dbt(["--no-write-json", "run"]) + assert len(results) == 1