From 0a40352e08e5f220dde3a3c5aede8e2f7d9fbe6a Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Fri, 6 Dec 2024 16:10:36 -0600 Subject: [PATCH] Fix MicrobatchModelRunner.on_skip to handle skipping the entire node Previously `MicrobatchModelRunner.on_skip` only handled when a _batch_ of the model was being skipped. However, that method is also used when the entire microbatch model is being skipped due to an upstream node error. Because we previously _weren't_ handling this second case, it'd cause an unhandled runtime exception. Thus we now need to check whether we're running a batch or not, and there is no batch, then use the super's on_skip method. --- core/dbt/task/run.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 6fa3fac9f2c..6e0800246d1 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -492,18 +492,22 @@ def merge_batch_results(self, result: RunResult, batch_results: List[RunResult]) result.batch_results.successful += self.node.previous_batch_results.successful def on_skip(self): - self.print_skip_batch_line() - return RunResult( - node=self.node, - status=RunStatus.Skipped, - timing=[], - thread_id=threading.current_thread().name, - execution_time=0.0, - message="SKIPPED", - adapter_response={}, - failures=1, - batch_results=BatchResults(failed=[self.batches[self.batch_idx]]), - ) + # If node.batch is None, then we're dealing with skipping of the entire node + if self.node.batch is None: + return super().on_skip() + else: + self.print_skip_batch_line() + return RunResult( + node=self.node, + status=RunStatus.Skipped, + timing=[], + thread_id=threading.current_thread().name, + execution_time=0.0, + message="SKIPPED", + adapter_response={}, + failures=1, + batch_results=BatchResults(failed=[self.batches[self.batch_idx]]), + ) def _build_succesful_run_batch_result( self,