Skip to content

Commit

Permalink
run dbt tests in --indirect-selection buildable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
david-mag committed Oct 18, 2023
1 parent c82e6bc commit 0b98af6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions cosmos/airflow/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions cosmos/operators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/airflow/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 0b98af6

Please sign in to comment.