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

[Bug] [Spike] indirect_selection in yaml selector definition doesn't work #9776

Closed
gshank opened this issue Mar 19, 2024 · 4 comments · Fixed by #10009
Closed

[Bug] [Spike] indirect_selection in yaml selector definition doesn't work #9776

gshank opened this issue Mar 19, 2024 · 4 comments · Fixed by #10009
Assignees
Labels
bug Something isn't working
Milestone

Comments

@gshank
Copy link
Contributor

gshank commented Mar 19, 2024

Current behavior

With a yaml selector in selectors.yml, indirect_selection doesn't work:

  - name: buildable_selector
    definition:
      union:
        - method: path
          value: models/some_output.sql
          children: false
          parents: true
          indirect_selection: buildable

If the same selector is defined using the CLI and --indirect-selection, it does work.

Expected behavior

"indirect_selection" defined in a yaml selectors works as expected.

Steps to reproduce

Create a selector with indirect_selection defined.

Relevant log output

Acceptance Criteria

As a part of the spike, please create a readme in GH with your findings to make it easier for future engineers to work in this code.

Additional context

Unclear if this ever worked.
Assess what it would take to support this or if we shouldn't support this and update documentation.
This code is hard to work on, may require clean up in process.

https://docs.getdbt.com/reference/node-selection/yaml-selectors#indirect-selection

It looks like some code was added last year via a community contributor PR which doesn't function as expected for yaml selectors.

See also #7673

@martynydbt martynydbt added the bug Something isn't working label Mar 19, 2024
@graciegoheen graciegoheen added this to the v1.8 milestone Apr 1, 2024
@martynydbt martynydbt added the High Severity bug with significant impact that should be resolved in a reasonable timeframe label Apr 1, 2024
@martynydbt martynydbt changed the title [Bug] indirect_selection in yaml selector definition doesn't work [Bug] [Spike] indirect_selection in yaml selector definition doesn't work Apr 1, 2024
@martynydbt martynydbt removed the High Severity bug with significant impact that should be resolved in a reasonable timeframe label Apr 1, 2024
@ChenyuLInx
Copy link
Contributor

We should write some brief docs about how selector works in general and have that added to the repo as a read me

@ChenyuLInx
Copy link
Contributor

@gshank What I found is that the indirect selection in selectors.yml works, but you cannot overwrite it with args passed in from CLI.

So for this jaffle shop model orders, I defined a selectors.yml looking like this

selectors:
  - name: nodes_to_joy
    definition:
      union:
        - method: path
          value: models/marts/orders.sql
          children: false
          parents: false
          indirect_selection: buildable

And by changing the indirect_selection value and run dbt ls --selector nodes_to_joy, I found that the number of things being selected goes from 3 to 4, which means it works.
But if I try to run dbt ls --selector nodes_to_joy --indirect-selection eager with buildable as a value inside, I see effect of buildable indirect selection.
If I do not specify indirect-selection in the yaml selectors file, I see the effect of eager and can't overwrite it with CLI args.

This doesn't match this PR description but matches what Doug said in his issue. Thouths? Any issue with the way I test?

@ChenyuLInx
Copy link
Contributor

I did find out the reason for the behavior Doug mentioned is that the rendered.selectors_dict here does not contain a resolved dict that has default value inside.

@gshank do you know in other places how do we resolve these kind of stuff? I think we should probably setup a patten to do resolution(CLI, env var, project file definition).

@gshank
Copy link
Contributor Author

gshank commented Apr 17, 2024

We do that kind of resolution in the flags.py file, so I guess this is similar to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants