From f7ab48759dc815c7d739e6bef5052fedca3a0977 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:13:17 -0600 Subject: [PATCH] Fix microbatch model `PartialSuccess` status to result in non-zero exit code (#11115) (#11118) * Update partial success test to assert partial successes mean that the run failed * Update results interpretation to include `PartialSuccess` as failure status (cherry picked from commit 983cbb4f285f263adf7ce538c50a637a53c43b4b) Co-authored-by: Quigley Malcolm --- .changes/unreleased/Fixes-20241209-150711.yaml | 6 ++++++ core/dbt/task/runnable.py | 1 + tests/functional/microbatch/test_microbatch.py | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixes-20241209-150711.yaml diff --git a/.changes/unreleased/Fixes-20241209-150711.yaml b/.changes/unreleased/Fixes-20241209-150711.yaml new file mode 100644 index 00000000000..a9522145abe --- /dev/null +++ b/.changes/unreleased/Fixes-20241209-150711.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix interpretation of `PartialSuccess` to result in non-zero exit code +time: 2024-12-09T15:07:11.391313-06:00 +custom: + Author: QMalcolm + Issue: "11114" diff --git a/core/dbt/task/runnable.py b/core/dbt/task/runnable.py index b889558d048..55342cafbbc 100644 --- a/core/dbt/task/runnable.py +++ b/core/dbt/task/runnable.py @@ -626,6 +626,7 @@ def interpret_results(cls, results): NodeStatus.Error, NodeStatus.Fail, NodeStatus.Skipped, # propogate error message causing skip + NodeStatus.PartialSuccess, # because partial success also means partial failure ) ] return len(failures) == 0 diff --git a/tests/functional/microbatch/test_microbatch.py b/tests/functional/microbatch/test_microbatch.py index 8567dbe67a4..c31657d94fc 100644 --- a/tests/functional/microbatch/test_microbatch.py +++ b/tests/functional/microbatch/test_microbatch.py @@ -613,7 +613,7 @@ def models(self): def test_run_with_event_time(self, project): # run all partitions from start - 2 expected rows in output, one failed with patch_microbatch_end_time("2020-01-03 13:57:00"): - _, console_output = run_dbt_and_capture(["run"]) + _, console_output = run_dbt_and_capture(["run"], expect_pass=False) assert "PARTIAL SUCCESS (2/3)" in console_output assert "Completed with 1 partial success" in console_output @@ -652,7 +652,7 @@ def models(self): def test_run_with_event_time(self, project): # run all partitions from start - 2 expected rows in output, one failed with patch_microbatch_end_time("2020-01-03 13:57:00"): - _, console_output = run_dbt_and_capture(["run"]) + _, console_output = run_dbt_and_capture(["run"], expect_pass=False) assert "PARTIAL SUCCESS (2/3)" in console_output assert "Completed with 1 partial success" in console_output @@ -751,7 +751,7 @@ def test_run_with_event_time(self, project): # run all partitions from start - 2 expected rows in output, one failed with patch_microbatch_end_time("2020-01-03 13:57:00"): - run_dbt(["run"], callbacks=[event_catcher.catch]) + run_dbt(["run"], expect_pass=False, callbacks=[event_catcher.catch]) assert len(event_catcher.caught_events) == 1 self.assert_row_count(project, "microbatch_model", 2)