Skip to content

Commit

Permalink
Rebase and update tests that broke upon rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
tseruga committed Oct 10, 2023
1 parent b0effc1 commit 74d1b8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cosmos/dbt/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def select_nodes_ids_by_dfs(nodes: dict[str, DbtNode], config: SelectorConfig) -
break

if not root:
logging.warn("Model in selector not found in DBT graph")
return set()

selected_nodes = set()
Expand Down Expand Up @@ -233,7 +232,11 @@ def select_nodes(
filters = [["select", select], ["exclude", exclude]]
for filter_type, filter in filters:
for filter_parameter in filter:
if filter_parameter.startswith(PATH_SELECTOR) or filter_parameter.startswith(TAG_SELECTOR):
if (
filter_parameter.startswith(PATH_SELECTOR)
or filter_parameter.startswith(TAG_SELECTOR)
or filter_parameter.startswith(MODEL_UPSTREAM_SELECTOR)
):
continue
elif any([filter_parameter.startswith(CONFIG_SELECTOR + config + ":") for config in SUPPORTED_CONFIG]):
continue
Expand Down
15 changes: 15 additions & 0 deletions tests/dbt/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ def test_select_nodes_by_exclude_union_config_test_tags():
)
expected = {
grandparent_node.unique_id: grandparent_node,
grandparent_sibling_node.unique_id: grandparent_sibling_node,
parent_node.unique_id: parent_node,
child_node.unique_id: child_node,
orphaned_node.unique_id: orphaned_node,
}
assert selected == expected


def test_select_nodes_by_dfs():
selected = select_nodes(project_dir=SAMPLE_PROJ_PATH, nodes=sample_nodes, select=["+child"])
expected = {
Expand All @@ -247,6 +255,11 @@ def test_select_nodes_by_path_dir():
child_node.unique_id: child_node,
grandchild_1_test_node.unique_id: grandchild_1_test_node,
grandchild_2_test_node.unique_id: grandchild_2_test_node,
orphaned_node.unique_id: orphaned_node,
}
assert selected == expected


def test_select_nodes_by_dfs_exclude_tags():
selected = select_nodes(
project_dir=SAMPLE_PROJ_PATH, nodes=sample_nodes, select=["+child"], exclude=["tag:has_child"]
Expand All @@ -264,6 +277,8 @@ def test_select_nodes_by_path_file():
parent_node.unique_id: parent_node,
}
assert selected == expected


def test_select_node_by_dfs_partial_tree():
selected = select_nodes(project_dir=SAMPLE_PROJ_PATH, nodes=sample_nodes, select=["+parent"])
expected = {
Expand Down

0 comments on commit 74d1b8f

Please sign in to comment.