Skip to content

Commit

Permalink
Fix conditional logic for setting pre and post hooks for batches
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
QMalcolm committed Dec 6, 2024
1 parent 7699f52 commit 74a76c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 74a76c4

Please sign in to comment.