From f3767609435a4245f8b9879e12eb089d34c9c55f Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Tue, 12 Nov 2024 14:11:24 -0600 Subject: [PATCH] Fix microbatch behavior flag check Previously we were adding `microbatch` to the list of `builtin_incremental_strategies` only when the behavior flag `require_batched_execution_for_custom_microbatch_strategy` was set to True. However in reality, we only want to set it True when that flag evaluates to False. This is because having the flag set to True implies by the transitive property that the project has a custom microbatch macro defined. In this situation, we _don't_ want `microbatch` to be in the list of `builtins` because if the adapter doesn't have a builtin `microbatch` macro, things will break. Said another way, the only time that having `microbatch` in the list of builtin incremental strategies is relevant is when the flag is False. --- .changes/unreleased/Fixes-20241112-141109.yaml | 6 ++++++ dbt/adapters/base/impl.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixes-20241112-141109.yaml diff --git a/.changes/unreleased/Fixes-20241112-141109.yaml b/.changes/unreleased/Fixes-20241112-141109.yaml new file mode 100644 index 00000000..46df4e48 --- /dev/null +++ b/.changes/unreleased/Fixes-20241112-141109.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Negate the check for microbatch behavior flag in determining builtins +time: 2024-11-12T14:11:09.341634-06:00 +custom: + Author: QMalcolm + Issue: 349 diff --git a/dbt/adapters/base/impl.py b/dbt/adapters/base/impl.py index c8457e2f..752389c1 100644 --- a/dbt/adapters/base/impl.py +++ b/dbt/adapters/base/impl.py @@ -1579,7 +1579,7 @@ def valid_incremental_strategies(self): def builtin_incremental_strategies(self): builtin_strategies = ["append", "delete+insert", "merge", "insert_overwrite"] - if self.behavior.require_batched_execution_for_custom_microbatch_strategy.no_warn: + if not self.behavior.require_batched_execution_for_custom_microbatch_strategy.no_warn: builtin_strategies.append("microbatch") return builtin_strategies