From d02766d3c14a97a02def5d727a38e017056806af Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 13 Nov 2024 17:14:48 +0000 Subject: [PATCH 1/2] Fix #10988: Validate manifest has group_map during group_lookup init --- .changes/unreleased/Fixes-20241113-171516.yaml | 6 ++++++ core/dbt/task/group_lookup.py | 3 +++ tests/functional/logging/test_logging.py | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 .changes/unreleased/Fixes-20241113-171516.yaml 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..efe8a856dd7 100644 --- a/core/dbt/task/group_lookup.py +++ b/core/dbt/task/group_lookup.py @@ -11,6 +11,9 @@ def init(manifest: Optional[Manifest], selected_ids: AbstractSet[str]) -> None: if not manifest: return + if not manifest.groups: + return + _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 From 9920ce4196a21329b0688c6818f9d2ba39c5e1f7 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Thu, 14 Nov 2024 15:37:06 +0000 Subject: [PATCH 2/2] Add group_map check --- core/dbt/task/group_lookup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/dbt/task/group_lookup.py b/core/dbt/task/group_lookup.py index efe8a856dd7..40f21cbe511 100644 --- a/core/dbt/task/group_lookup.py +++ b/core/dbt/task/group_lookup.py @@ -14,6 +14,9 @@ def init(manifest: Optional[Manifest], selected_ids: AbstractSet[str]) -> None: 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():