From 7382971622d464b2cdc48c8d1c85318583b2c8f6 Mon Sep 17 00:00:00 2001 From: Andrew Sweet Date: Sat, 23 Mar 2024 20:02:56 -0400 Subject: [PATCH 1/4] Add fnMatch to group selectors --- core/dbt/graph/selector_methods.py | 2 +- tests/unit/test_graph_selector_methods.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/dbt/graph/selector_methods.py b/core/dbt/graph/selector_methods.py index a9cc6eabbbb..87190c047bb 100644 --- a/core/dbt/graph/selector_methods.py +++ b/core/dbt/graph/selector_methods.py @@ -277,7 +277,7 @@ class GroupSelectorMethod(SelectorMethod): def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[UniqueId]: """yields nodes from included in the specified group""" for node, real_node in self.groupable_nodes(included_nodes): - if selector == real_node.config.get("group"): + if fnmatch(selector, real_node.config.get("group")): yield node diff --git a/tests/unit/test_graph_selector_methods.py b/tests/unit/test_graph_selector_methods.py index ee2c2c4d968..52013fd409d 100644 --- a/tests/unit/test_graph_selector_methods.py +++ b/tests/unit/test_graph_selector_methods.py @@ -1056,6 +1056,7 @@ def test_select_group(manifest, view_model): assert method.arguments == [] assert search_manifest_using_method(manifest, method, group_name) == {"view_model"} + assert search_manifest_using_method(manifest, method, "my?group") == {"view_model"} assert not search_manifest_using_method(manifest, method, "not_my_group") From 8dd90fe7842a4bdca7efc5f9f0e3d7ac9923d2dc Mon Sep 17 00:00:00 2001 From: Andrew Sweet Date: Sat, 23 Mar 2024 20:12:35 -0400 Subject: [PATCH 2/4] Changeset --- .changes/unreleased/Features-20240323-201230.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20240323-201230.yaml diff --git a/.changes/unreleased/Features-20240323-201230.yaml b/.changes/unreleased/Features-20240323-201230.yaml new file mode 100644 index 00000000000..3f981ecc7b3 --- /dev/null +++ b/.changes/unreleased/Features-20240323-201230.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Add wildcard support to the group selector method +time: 2024-03-23T20:12:30.715975-04:00 +custom: + Author: heysweet + Issue: "9811" From b14ec651d61f20ae983ac5f1fcbf237e3cfb79ed Mon Sep 17 00:00:00 2001 From: Andrew Sweet Date: Sat, 23 Mar 2024 20:23:18 -0400 Subject: [PATCH 3/4] Fix none group case --- core/dbt/graph/selector_methods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/dbt/graph/selector_methods.py b/core/dbt/graph/selector_methods.py index 87190c047bb..629158a95d4 100644 --- a/core/dbt/graph/selector_methods.py +++ b/core/dbt/graph/selector_methods.py @@ -277,7 +277,8 @@ class GroupSelectorMethod(SelectorMethod): def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[UniqueId]: """yields nodes from included in the specified group""" for node, real_node in self.groupable_nodes(included_nodes): - if fnmatch(selector, real_node.config.get("group")): + node_group = real_node.config.get("group") + if node_group and fnmatch(selector, node_group): yield node From 618957eaac3553c966e84bd191b93d0eb54abab2 Mon Sep 17 00:00:00 2001 From: Andrew Sweet Date: Sat, 23 Mar 2024 20:45:26 -0400 Subject: [PATCH 4/4] fn order --- core/dbt/graph/selector_methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/graph/selector_methods.py b/core/dbt/graph/selector_methods.py index 629158a95d4..e7b071769a4 100644 --- a/core/dbt/graph/selector_methods.py +++ b/core/dbt/graph/selector_methods.py @@ -278,7 +278,7 @@ def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[Uniqu """yields nodes from included in the specified group""" for node, real_node in self.groupable_nodes(included_nodes): node_group = real_node.config.get("group") - if node_group and fnmatch(selector, node_group): + if node_group and fnmatch(node_group, selector): yield node