From 74a76c4db4137932eefb4a5e1539d8203d8f10cd Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Fri, 6 Dec 2024 16:20:16 -0600 Subject: [PATCH] Fix conditional logic for setting pre and post hooks for batches Previously we were doign an if+elif for setting pre and post hooks for batches, where in the `if` matched if the batch wasn't the first batch, and the `elif` matched if the batch wasn't the last batch. The issue with this is that if the `if` was hit the `elif` _wouldn't_ be hit. This caused the first batch to appropriately not run the `post-hook` but then every hook after would run the `post-hook`. --- core/dbt/task/run.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 4e9bd6cfb28..828e3a79e64 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -813,8 +813,9 @@ def _submit_batch( # Only run pre_hook(s) for first batch if batch_idx != 0: node_copy.config.pre_hook = [] + # Only run post_hook(s) for last batch - elif batch_idx != len(batches) - 1: + if batch_idx != len(batches) - 1: node_copy.config.post_hook = [] batch_runner = self.get_runner(node_copy)