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

Conversation

barton996
Copy link
Contributor

@barton996 barton996 commented Dec 12, 2023

resolves #6891

Problem

There are many use cases where it is useful to exclude models not in your package from your run selection.

There is no easy way to limit your selection to just models in your project without resorting to hardcoding in package names.

Solution

This change adds 'this' as a valid package selector, enabling statements like dbt ls -s package:this

Running the selector above will return just the models from the current project.

User documentation

User docs for this feature should be added here:
https://docs.getdbt.com/reference/node-selection/methods#the-package-method

The examples can be updated to look like this:

# These three selectors are equivalent
dbt run --select "package:snowplow"
dbt run --select "snowplow"
dbt run --select "snowplow.*"

dbt run --select "package:this"  # only run models in the current dbt project 

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has already received feedback and approval from Product or DX within #6891
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Dec 12, 2023
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@barton996 barton996 marked this pull request as ready for review December 12, 2023 17:00
@barton996 barton996 requested a review from a team as a code owner December 12, 2023 17:00
@barton996 barton996 requested a review from gshank December 12, 2023 17:00
@barton996
Copy link
Contributor Author

barton996 commented Dec 12, 2023

@dbeatty10 @graciegoheen @gwenwindflower
image

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.14%. Comparing base (bcbde3a) to head (502d661).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9270      +/-   ##
==========================================
- Coverage   88.22%   88.14%   -0.08%     
==========================================
  Files         181      181              
  Lines       22643    22645       +2     
==========================================
- Hits        19976    19961      -15     
- Misses       2667     2684      +17     
Flag Coverage Δ
integration 85.43% <0.00%> (-0.15%) ⬇️
unit 62.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dbeatty10 dbeatty10 added the user docs [docs.getdbt.com] Needs better documentation label Dec 12, 2023
@dbeatty10 dbeatty10 added the community This PR is from a community member label Mar 22, 2024
@jtcohen6 jtcohen6 added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Apr 12, 2024
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barton996 Thank you for this PR! :)

@aranke and I revisited the question of what syntax makes most sense here, and after some more discussion, we think we prefer package:this over package:. (despite what I said a year ago). If you're amenable to that change, let's make it happen.

core/dbt/graph/selector_methods.py Outdated Show resolved Hide resolved
@aranke aranke requested review from jtcohen6 and dbeatty10 April 26, 2024 12:28
@aranke aranke merged commit 01f5dc8 into dbt-labs:main May 1, 2024
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes community This PR is from a community member ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2059] [Feature] Syntax to restrict selection to the current package
5 participants