From 8639290108d78c826c4902cc82332eb944ed6d53 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Wed, 12 Jun 2024 14:16:54 -0700 Subject: [PATCH] update on_skip to adjust for node that do not have schema (#10302) * update on_skip to adjust for node that do not have schema * changelog --- .changes/unreleased/Fixes-20240612-124256.yaml | 6 ++++++ core/dbt/task/base.py | 2 +- tests/unit/task/test_build.py | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixes-20240612-124256.yaml create mode 100644 tests/unit/task/test_build.py diff --git a/.changes/unreleased/Fixes-20240612-124256.yaml b/.changes/unreleased/Fixes-20240612-124256.yaml new file mode 100644 index 00000000000..2528ebe539a --- /dev/null +++ b/.changes/unreleased/Fixes-20240612-124256.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Saved Query node fail during skip +time: 2024-06-12T12:42:56.329073-07:00 +custom: + Author: ChenyuLInx + Issue: "10029" diff --git a/core/dbt/task/base.py b/core/dbt/task/base.py index dfade18f1ab..df09a507e16 100644 --- a/core/dbt/task/base.py +++ b/core/dbt/task/base.py @@ -410,7 +410,7 @@ def _skip_caused_by_ephemeral_failure(self): return self.skip_cause.node.is_ephemeral_model def on_skip(self): - schema_name = self.node.schema + schema_name = getattr(self.node, "schema", "") node_name = self.node.name error_message = None diff --git a/tests/unit/task/test_build.py b/tests/unit/task/test_build.py new file mode 100644 index 00000000000..87d7b081ae8 --- /dev/null +++ b/tests/unit/task/test_build.py @@ -0,0 +1,14 @@ +from dbt.contracts.graph.nodes import SavedQuery +from dbt.task.build import SavedQueryRunner + + +def test_saved_query_runner_on_skip(saved_query: SavedQuery): + runner = SavedQueryRunner( + config=None, + adapter=None, + node=saved_query, + node_index=None, + num_nodes=None, + ) + # on_skip would work + runner.on_skip()