Skip to content

Commit

Permalink
CT-3144 Fix test edges type filter on Graph (#8696)
Browse files Browse the repository at this point in the history
* CT-3144 Fix test edges filter

* CT-3144 Add changelog

* CT-3144 Remove duplicated line

* CT-3144 Remove duplicated line

* CT-3144 Rename vars

* CT-3144 Update filter to use get_edge_data

* Trigger cla
  • Loading branch information
renanleme authored and QMalcolm committed Oct 6, 2023
1 parent 90b9abc commit 03ff275
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230922-223313.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fixes test type edges filter
time: 2023-09-22T22:33:13.200662+02:00
custom:
Author: renanleme
Issue: "8692"
13 changes: 6 additions & 7 deletions core/dbt/graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Set, Iterable, Iterator, Optional, NewType
from itertools import product
import networkx as nx # type: ignore
from functools import partial

from dbt.exceptions import DbtInternalError

Expand Down Expand Up @@ -42,16 +43,14 @@ def descendants(self, node: UniqueId, max_depth: Optional[int] = None) -> Set[Un
return {child for _, child in nx.bfs_edges(filtered_graph, node, depth_limit=max_depth)}

def exclude_edge_type(self, edge_type_to_exclude):
return nx.restricted_view(
return nx.subgraph_view(
self.graph,
nodes=[],
edges=(
(a, b)
for a, b in self.graph.edges
if self.graph[a][b].get("edge_type") == edge_type_to_exclude
),
filter_edge=partial(self.filter_edges_by_type, edge_type=edge_type_to_exclude),
)

def filter_edges_by_type(self, first_node, second_node, edge_type):
return self.graph.get_edge_data(first_node, second_node).get("edge_type") != edge_type

def select_childrens_parents(self, selected: Set[UniqueId]) -> Set[UniqueId]:
ancestors_for = self.select_children(selected) | selected
return self.select_parents(ancestors_for) | ancestors_for
Expand Down

0 comments on commit 03ff275

Please sign in to comment.