Skip to content

Commit

Permalink
Rename microbatch behavior flag to `require_batched_execution_for_cus…
Browse files Browse the repository at this point in the history
…tom_microbatch_strategy`
  • Loading branch information
QMalcolm committed Nov 5, 2024
1 parent e77a13c commit 543e024
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,8 +1765,9 @@ def _microbatch_macro_is_root(self, project_name: str, adapter_type: str) -> boo
return microbatch_is_root

def use_microbatch_batches(self, project_name: str, adapter_type: str) -> bool:
return get_flags().require_builtin_microbatch_strategy or self._microbatch_macro_is_root(
project_name=project_name, adapter_type=adapter_type
return (
get_flags().require_batched_execution_for_custom_microbatch_strategy
or self._microbatch_macro_is_root(project_name=project_name, adapter_type=adapter_type)
)


Expand Down
4 changes: 2 additions & 2 deletions core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ProjectFlags(ExtensibleDbtClassMixin):
write_json: Optional[bool] = None

# legacy behaviors - https://github.com/dbt-labs/dbt-core/blob/main/docs/guides/behavior-change-flags.md
require_builtin_microbatch_strategy: bool = False
require_batched_execution_for_custom_microbatch_strategy: bool = False
require_explicit_package_overrides_for_builtin_materializations: bool = True
require_resource_names_without_spaces: bool = False
source_freshness_run_project_hooks: bool = False
Expand All @@ -350,7 +350,7 @@ class ProjectFlags(ExtensibleDbtClassMixin):
@property
def project_only_flags(self) -> Dict[str, Any]:
return {
"require_builtin_microbatch_strategy": self.require_builtin_microbatch_strategy,
"require_batched_execution_for_custom_microbatch_strategy": self.require_batched_execution_for_custom_microbatch_strategy,
"require_explicit_package_overrides_for_builtin_materializations": self.require_explicit_package_overrides_for_builtin_materializations,
"require_resource_names_without_spaces": self.require_resource_names_without_spaces,
"source_freshness_run_project_hooks": self.source_freshness_run_project_hooks,
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/microbatch/test_microbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def macros(self):
def project_config_update(self):
return {
"flags": {
"require_builtin_microbatch_strategy": True,
"require_batched_execution_for_custom_microbatch_strategy": True,
}
}

Expand All @@ -165,7 +165,7 @@ class TestMicrobatchCustomUserStrategyDefault(BaseMicrobatchCustomUserStrategy):
def project_config_update(self):
return {
"flags": {
"require_builtin_microbatch_strategy": False,
"require_batched_execution_for_custom_microbatch_strategy": False,
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ def models(self):
def project_config_update(self):
return {
"flags": {
"require_builtin_microbatch_strategy": True,
"require_batched_execution_for_custom_microbatch_strategy": True,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def models(self):
def project_config_update(self):
return {
"flags": {
"require_builtin_microbatch_strategy": True,
"require_batched_execution_for_custom_microbatch_strategy": True,
}
}

Expand All @@ -105,7 +105,7 @@ def models(self):
def project_config_update(self):
return {
"flags": {
"require_builtin_microbatch_strategy": True,
"require_batched_execution_for_custom_microbatch_strategy": True,
}
}

Expand Down
13 changes: 10 additions & 3 deletions tests/unit/context/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def test_resolve_event_time_filter(
expect_filter: bool,
) -> None:
set_from_args(
Namespace(require_builtin_microbatch_strategy=dbt_experimental_microbatch), None
Namespace(
require_batched_execution_for_custom_microbatch_strategy=dbt_experimental_microbatch
),
None,
)

# Target mocking
Expand Down Expand Up @@ -119,7 +122,9 @@ def test_create_relation_with_empty(self, resolver, empty, is_ephemeral_model, e
mock_node.is_ephemeral_model = is_ephemeral_model
mock_node.defer_relation = None

set_from_args(Namespace(require_builtin_microbatch_strategy=False), None)
set_from_args(
Namespace(require_batched_execution_for_custom_microbatch_strategy=False), None
)

# create limited relation
with mock.patch("dbt.contracts.graph.nodes.ParsedNode", new=mock.Mock):
Expand Down Expand Up @@ -160,7 +165,9 @@ def test_create_relation_with_empty(self, resolver, empty, expected_limit):
mock_source.quoting_dict = {}
resolver.manifest.resolve_source.return_value = mock_source

set_from_args(Namespace(require_builtin_microbatch_strategy=False), None)
set_from_args(
Namespace(require_batched_execution_for_custom_microbatch_strategy=False), None
)

# create limited relation
relation = resolver.resolve("test", "test")
Expand Down

0 comments on commit 543e024

Please sign in to comment.