diff --git a/cosmos/airflow/graph.py b/cosmos/airflow/graph.py index 3e7961ed1..d29ff1bfa 100644 --- a/cosmos/airflow/graph.py +++ b/cosmos/airflow/graph.py @@ -71,6 +71,7 @@ def create_test_task_metadata( """ task_args = dict(task_args) task_args["on_warning_callback"] = on_warning_callback + task_args["indirect_selection"] = "buildable" if node is not None: if node.resource_type == DbtResourceType.MODEL: task_args["models"] = node.name diff --git a/cosmos/operators/base.py b/cosmos/operators/base.py index d43a2d241..6d276013d 100644 --- a/cosmos/operators/base.py +++ b/cosmos/operators/base.py @@ -89,6 +89,7 @@ def __init__( vars: dict[str, str] | None = None, models: str | None = None, emit_datasets: bool = True, + indirect_selection: str | None = None, cache_selected_only: bool = False, no_version_check: bool = False, fail_fast: bool = False, @@ -115,6 +116,7 @@ def __init__( self.vars = vars self.models = models self.emit_datasets = emit_datasets + self.indirect_selection = indirect_selection self.cache_selected_only = cache_selected_only self.no_version_check = no_version_check self.fail_fast = fail_fast @@ -213,6 +215,9 @@ def build_cmd( if self.base_cmd: dbt_cmd.extend(self.base_cmd) + if self.indirect_selection: + dbt_cmd += ["--indirect-selection", self.indirect_selection] + dbt_cmd.extend(self.add_global_flags()) # add command specific flags diff --git a/tests/airflow/test_graph.py b/tests/airflow/test_graph.py index 2eb93c613..93bb47bfd 100644 --- a/tests/airflow/test_graph.py +++ b/tests/airflow/test_graph.py @@ -359,4 +359,4 @@ def test_create_test_task_metadata(node_type, node_unique_id, selector_key, sele ) assert metadata.id == "test_no_nulls" assert metadata.operator_class == "cosmos.operators.local.DbtTestLocalOperator" - assert metadata.arguments == {"task_arg": "value", "on_warning_callback": True, selector_key: selector_value} + assert metadata.arguments == {"task_arg": "value", 'indirect_selection': 'buildable', "on_warning_callback": True, selector_key: selector_value}