From a2b3fdda30196e09c84392de83c1f304191df950 Mon Sep 17 00:00:00 2001 From: Kiran Vasudev Date: Thu, 7 Dec 2023 19:54:18 +0100 Subject: [PATCH] fix: follow external dependency for staging models --- dagger/utilities/dbt_config_parser.py | 9 +++++++-- .../modules/dbt_config_parser_fixtures.py | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dagger/utilities/dbt_config_parser.py b/dagger/utilities/dbt_config_parser.py index dd16008..15f31df 100644 --- a/dagger/utilities/dbt_config_parser.py +++ b/dagger/utilities/dbt_config_parser.py @@ -112,7 +112,10 @@ def _generate_dagger_output(self, node: dict): dict: The dagger output, which is a combination of an athena and s3 task for the DBT model node """ - if node.get("config", {}).get("materialized") in ("view", "ephemeral"): + if node.get("config", {}).get("materialized") in ( + "view", + "ephemeral", + ) or node.get("name").startswith("stg_"): return [self._get_dummy_task(node)] else: return [self._get_athena_task(node), self._get_s3_task(node)] @@ -150,7 +153,9 @@ def _generate_dagger_tasks( task = self._get_dummy_task(node, follow_external_dependency=True) dagger_tasks.append(task) elif node.get("name").startswith("stg_"): - dagger_tasks.append(self._get_dummy_task(node)) + dagger_tasks.append( + self._get_dummy_task(node, follow_external_dependency=True) + ) else: athena_task = self._get_athena_task(node, follow_external_dependency=True) s3_task = self._get_s3_task(node) diff --git a/tests/fixtures/modules/dbt_config_parser_fixtures.py b/tests/fixtures/modules/dbt_config_parser_fixtures.py index 2f42778..90ebf03 100644 --- a/tests/fixtures/modules/dbt_config_parser_fixtures.py +++ b/tests/fixtures/modules/dbt_config_parser_fixtures.py @@ -164,7 +164,11 @@ } EXPECTED_STAGING_NODE = [ - {"name": "stg_core_schema1__table1", "type": "dummy"}, + { + "name": "stg_core_schema1__table1", + "type": "dummy", + "follow_external_dependency": True, + }, ] EXPECTED_SEED_NODE = [ @@ -197,7 +201,11 @@ "type": "dummy", "name": "seed_buyer_country_overwrite", }, - {"name": "stg_core_schema2__table2", "type": "dummy"} + { + "name": "stg_core_schema2__table2", + "type": "dummy", + "follow_external_dependency": True, + }, ] EXPECTED_EPHEMERAL_NODE = [ @@ -225,7 +233,11 @@ ] EXPECTED_DAGGER_INPUTS = [ - {"name": "stg_core_schema2__table2", "type": "dummy"}, + { + "name": "stg_core_schema2__table2", + "type": "dummy", + "follow_external_dependency": True, + }, { "name": "analytics_engineering__model2_athena", "schema": "analytics_engineering",