Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current package selection syntax #9270

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20231212-163409.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Package selector syntax for the current package
time: 2023-12-12T16:34:09.328891Z
custom:
Author: barton996
Issue: "6891"
5 changes: 4 additions & 1 deletion core/dbt/graph/selector_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,10 @@ class PackageSelectorMethod(SelectorMethod):
def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[UniqueId]:
"""Yields nodes from included that have the specified package"""
for node, real_node in self.all_nodes(included_nodes):
if fnmatch(real_node.package_name, selector):
if selector == "." and self.manifest.metadata.project_name is not None:
if fnmatch(real_node.package_name, self.manifest.metadata.project_name):
yield node
elif fnmatch(real_node.package_name, selector):
barton996 marked this conversation as resolved.
Show resolved Hide resolved
yield node


Expand Down
27 changes: 26 additions & 1 deletion tests/unit/test_graph_selector_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,10 @@ def manifest(
disabled=[],
selectors={},
groups={},
metadata=ManifestMetadata(adapter_type="postgres"),
metadata=ManifestMetadata(
adapter_type="postgres",
project_name="pkg",
),
)
return manifest

Expand Down Expand Up @@ -1144,6 +1147,28 @@ def test_select_package(manifest):
"mynamespace.ephemeral_model",
"mynamespace.union_model",
}
assert search_manifest_using_method(manifest, method, ".") == {
"union_model",
"versioned_model.v1",
"versioned_model.v2",
"versioned_model.v3",
"versioned_model.v4",
"versioned_model.v12",
"table_model",
"table_model_py",
"table_model_csv",
"view_model",
"ephemeral_model",
"seed",
"raw.seed",
"unique_table_model_id",
"not_null_table_model_id",
"unique_view_model_id",
"view_test_nothing",
"mynamespace.seed",
"mynamespace.ephemeral_model",
"mynamespace.union_model",
}
assert search_manifest_using_method(manifest, method, "ext") == {
"ext_model",
"ext_raw.ext_source",
Expand Down