fix: match bare wildcard FQN selectors against nested leaf names - #16348
Open
itsnamangoyal wants to merge 2 commits into
Open
itsnamangoyal wants to merge 2 commits into
itsnamangoyal wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Nested versioned models remain unfixed; add matching support and regression coverage.
Pull request overview
Fixes bare wildcard FQN selectors so they match nested model leaf names.
Changes:
- Adds leaf-level fallback matching for bare wildcards.
- Adds regression tests for root and nested models.
- Adds a changelog entry.
File summaries
| File | Description |
|---|---|
tests/unit/graph/test_selector_methods.py |
Adds wildcard selector regression tests. |
core/dbt/graph/selector_methods.py |
Implements nested leaf matching. |
.changes/unreleased/Fixes-20260917-224607.yaml |
Documents the fix. |
Review details
Suppressed comments (1)
core/dbt/graph/selector_methods.py:119
- This guard leaves nested versioned models unfixed: for an FQN such as
["my_pkg", "marts", "f_model", "v1"],f_*still fails the whole-FQNfnmatch, and the leaf fallback is skipped becauseis_versionedis true. The fallback should match the model-name segment (fqn[-2]) for versioned nodes, or otherwise explicitly preserve the version suffix while matching the bare pattern; please add a regression test for this case.
if not is_versioned and "." not in node_selector:
return fnmatch(fqn[-1], node_selector)
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The fallback still excludes nested versioned models from bare wildcard matching.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
Addresses review feedback on #16348: nested versioned models were excluded because the fqn's last segment is the version tag (e.g. "v4"), not the model name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CORE-937: a bare wildcard FQN selector (e.g.-s "f_*", no dot) fails to match models nested in subfolders — it only matches root-level nodes.Repro:
Root cause
is_selected_node()incore/dbt/graph/selector_methods.pyflattens the node's FQN andfnmatchs the entire remaining dotted string against the selector once it hits a wildcard token. For a bare pattern likef_*(no dot), this requires the whole flattened FQN tail (e.g.marts.subdir.f_model) to start withf_, which only holds for root-level nodes whose FQN has no folder segments before the leaf name.Confirmed this behavior is identical (byte-for-byte function) across
1.10.latest,1.11.latest, and1.12.latest— every current v1 branch is affected. dbt Fusion (v2) has carried an explicit "bare wildcard-leaf shortcut" innode_selector.rssince May 2025 (an intentional Fusion-only addition, not something ever ported back to Python) — that's the actual origin of the parity gap, not the PR originally cited in the customer-facing Slack thread (which turned out to be an unrelatedpath:-selector directory-matching fix).Fix
In the wildcard-matching branch of
is_selected_node, if the existing flatten-and-fnmatchcheck doesn't match, and the selector is a bare wildcard (no dot), fall back to matching against just the FQN's leaf segment. This is additive — the original whole-FQN match (which also supports matching folder names, e.g.*unions*matching a directory literally namedunions) still runs first and is unchanged.Testing
test_qualified_name_bare_wildcard_matches_root_leaf(already passed pre-fix) andtest_qualified_name_bare_wildcard_matches_nested_leaf(red before, green after) totests/unit/graph/test_selector_methods.py, exercised throughQualifiedNameSelectorMethod.node_is_match— the real production entry point (which also retries against the package-unscoped FQN).tests/unit/graph/+tests/unit/test_graph_selection.pysuites (266 tests) pass with no regressions.jaffle-shopwith the actualdbtv1 CLI:dbt ls -s "stg_*"against the nestedmodels/staging/folder →No nodes selected!stg_*models + their generic tests correctly selectedpath:, dotted-FQN prefix, and exact-match selector forms.Test plan
tests/unit/graph/test_selector_methods.py,tests/unit/test_graph_selection.py)changie new