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

new node selectors (#2425) #2629

Merged
merged 2 commits into from
Jul 22, 2020
Merged

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Jul 15, 2020

resolves #2425

Description

Add the node selectors discussed in #2425, except I used test_type for differentiating schema and data tests, and test_name to differentiate between schema test names.

There's obviously lots of room for new selectors in addition to these, but this felt like a nice start.

Checklist

  • I have signed the CLA
  • 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
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Jul 15, 2020
@beckjake beckjake force-pushed the feature/advanced-node-selection branch 2 times, most recently from 5362acf to 6e161ab Compare July 15, 2020 23:25
@beckjake beckjake force-pushed the feature/new-node-selectors branch 2 times, most recently from 37c82d5 to 6a45b6a Compare July 17, 2020 19:44
- added a bunch of unit tests
- added some new integration tests
- cleaned up some selection logic
@beckjake beckjake force-pushed the feature/new-node-selectors branch from 6a45b6a to a523356 Compare July 20, 2020 17:16
Base automatically changed from feature/advanced-node-selection to dev/marian-anderson July 20, 2020 19:48
@beckjake beckjake marked this pull request as ready for review July 20, 2020 20:51
@beckjake beckjake requested review from jtcohen6 and kwigley July 20, 2020 22:05
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.

@beckjake This is really cool. The config selector in particular opens up a lot of doors. I left a comment around some config-based selectors that I'd expected to return nodes and came up empty.

After several minutes of trying to get the CLI arg syntax right, I'm all the more excited about our plans to support YML-configured selectors.

One surprise: the new node selectors do not seem to work with dbt ls. I frequently wanted to check selection syntax by seeing the list of included nodes before actually running/testing. If that's especially tricky to implement or out of scope of this PR, I'll open a separate issue and prioritize it.
User error :) these work perfectly with dbt ls -s, I forgot that dbt ls -m can only return model nodes.

core/dbt/graph/selector_methods.py Outdated Show resolved Hide resolved
def search(
self, included_nodes: Set[UniqueId], selector: str
) -> Iterator[UniqueId]:
parts = self.arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

This means all config arguments should be fair game for 'config.arg:value', right?

These worked for me on Fishtown's internal analytics project:

dbt run -m 'config.schema:analytics_utils'
dbt run -m 'config.materialized'
dbt test -m 'config.severity:error'

Whereas these did not match any nodes, when I believe they should have:

dbt run -m 'config.incremental_strategy:delete+insert'
dbt run -m 'config.unique_key:event_id'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, nice catch! That's because unique_key and incremental_strategy are special, so they don't show up to getattr. I'll change this to treat things like dictionaries when getattr fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, all work as expected

def search(
self, included_nodes: Set[UniqueId], selector: str
) -> Iterator[UniqueId]:
parts = self.arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, all work as expected

@beckjake beckjake merged commit 88e26da into dev/marian-anderson Jul 22, 2020
@beckjake
Copy link
Contributor Author

@kwigley sorry about that, I did not mean to merge it without your review, I mis-clicked! I'll open a PR to revert this.

@kwigley
Copy link
Contributor

kwigley commented Jul 22, 2020

@beckjake no worries! I got a chance to review this and don't have any meaningful feedback. Impl and tests looks great! no need to revert unless you think it is necessary

@beckjake beckjake deleted the feature/new-node-selectors branch July 22, 2020 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New CLI node selectors
3 participants