diff --git a/core/dbt/context/providers.py b/core/dbt/context/providers.py index e0c67ac2d99..0738db1a251 100644 --- a/core/dbt/context/providers.py +++ b/core/dbt/context/providers.py @@ -241,6 +241,7 @@ def resolve_event_time_filter(self, target: ManifestNode) -> Optional[EventTimeF os.environ.get("DBT_EXPERIMENTAL_MICROBATCH") and (isinstance(target.config, NodeConfig) or isinstance(target.config, SourceConfig)) and target.config.event_time + and isinstance(self.model, ModelNode) and self.model.config.materialized == "incremental" and self.model.config.incremental_strategy == "microbatch" ): diff --git a/tests/unit/context/test_providers.py b/tests/unit/context/test_providers.py index 54a5e067ad1..e2d5f2f99d3 100644 --- a/tests/unit/context/test_providers.py +++ b/tests/unit/context/test_providers.py @@ -13,6 +13,7 @@ RuntimeRefResolver, RuntimeSourceResolver, ) +from dbt.contracts.graph.nodes import ModelNode class TestBaseResolver: @@ -39,12 +40,13 @@ def test_resolve_limit(self, resolver, empty, expected_resolve_limit): assert resolver.resolve_limit == expected_resolve_limit @pytest.mark.parametrize( - "dbt_experimental_microbatch,materialized,incremental_strategy,expect_filter", + "dbt_experimental_microbatch,materialized,incremental_strategy,resolver_model_node,expect_filter", [ - (True, "incremental", "microbatch", True), - (False, "incremental", "microbatch", False), - (True, "table", "microbatch", False), - (True, "incremental", "merge", False), + (True, "incremental", "microbatch", True, True), + (True, "incremental", "microbatch", False, False), + (False, "incremental", "microbatch", True, False), + (True, "table", "microbatch", True, False), + (True, "incremental", "merge", True, False), ], ) def test_resolve_event_time_filter( @@ -54,6 +56,7 @@ def test_resolve_event_time_filter( dbt_experimental_microbatch: bool, materialized: str, incremental_strategy: str, + resolver_model_node: bool, expect_filter: bool, ) -> None: if dbt_experimental_microbatch: @@ -67,6 +70,8 @@ def test_resolve_event_time_filter( # Resolver mocking resolver.config.args.EVENT_TIME_END = None resolver.config.args.EVENT_TIME_START = None + if resolver_model_node: + resolver.model = mock.MagicMock(spec=ModelNode) resolver.model.config = mock.MagicMock(NodeConfig) resolver.model.config.materialized = materialized resolver.model.config.incremental_strategy = incremental_strategy