|
23 | 23 | Union,
|
24 | 24 | TYPE_CHECKING,
|
25 | 25 | )
|
26 |
| -import os |
27 | 26 | import pytz
|
28 | 27 | from dbt_common.behavior_flags import Behavior, BehaviorFlag
|
29 | 28 | from dbt_common.clients.jinja import CallableMacroGenerator
|
@@ -316,7 +315,13 @@ def _behavior_flags(self) -> List[BehaviorFlag]:
|
316 | 315 | """
|
317 | 316 | This method should be overwritten by adapter maintainers to provide platform-specific flags
|
318 | 317 | """
|
319 |
| - return [] |
| 318 | + return [ |
| 319 | + { |
| 320 | + "name": "require_batched_execution_for_custom_microbatch_strategy", |
| 321 | + "default": False, |
| 322 | + "docs_url": "https://docs.getdbt.com/docs/build/incremental-microbatch", |
| 323 | + } |
| 324 | + ] |
320 | 325 |
|
321 | 326 | ###
|
322 | 327 | # Methods that pass through to the connection manager
|
@@ -1574,13 +1579,24 @@ def valid_incremental_strategies(self):
|
1574 | 1579 |
|
1575 | 1580 | def builtin_incremental_strategies(self):
|
1576 | 1581 | builtin_strategies = ["append", "delete+insert", "merge", "insert_overwrite"]
|
1577 |
| - if os.environ.get("DBT_EXPERIMENTAL_MICROBATCH"): |
| 1582 | + if self.behavior.require_batched_execution_for_custom_microbatch_strategy.no_warn: |
1578 | 1583 | builtin_strategies.append("microbatch")
|
1579 | 1584 |
|
1580 | 1585 | return builtin_strategies
|
1581 | 1586 |
|
1582 | 1587 | @available.parse_none
|
1583 | 1588 | def get_incremental_strategy_macro(self, model_context, strategy: str):
|
| 1589 | + """Gets the macro for the given incremental strategy. |
| 1590 | +
|
| 1591 | + Additionally some validations are done: |
| 1592 | + 1. Assert that if the given strategy is a "builtin" strategy, then it must |
| 1593 | + also be defined as a "valid" strategy for the associated adapter |
| 1594 | + 2. Assert that the incremental strategy exists in the model context |
| 1595 | +
|
| 1596 | + Notably, something be defined by the adapter as "valid" without it being |
| 1597 | + a "builtin", and nothing will break (and that is desirable). |
| 1598 | + """ |
| 1599 | + |
1584 | 1600 | # Construct macro_name from strategy name
|
1585 | 1601 | if strategy is None:
|
1586 | 1602 | strategy = "default"
|
|
0 commit comments