-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-2635] [Feature] Node selection on versioned models should work with underscore-delimiting #7639
Comments
Thanks for raising this @joellabes! Let's assume the user has a models directory with files for versions
It seems like the issue you are trying to raise is that using the file name (without the extension) won't select the anticipated node? i.e., folks are used to being able to do this: dbt ls -s dim_customers_v1 But currently they would need to add a dbt ls -s dim_customers_v1.sql |
That’s correct - although I hadn't thought of filename selection, and assumed they would only be able to do The bones of my argument are that selection has always looked like you're using the file name, even if that isn't technically true, and so it is an (IMO unnecessary + unpleasant) surprise to discover that it doesn't work like that in this case |
@joellabes Agreed that it could be a little jarring to typically do I'd think that using the Potential solutionThe default selection methods are I didn't test it, but I'm guessing that if two more lines* are added that use Path.stem, then it might behave the way you describe: if fnmatch(Path(real_node.original_file_path).name, selector):
yield node
if fnmatch(Path(real_node.original_file_path).stem, selector):
yield node * Note: there's multiple ways to express logic similar to the above. Flip sideSuppose the user has a models directory with files for versions
The flip side is that it might be surprising to those same people that Refinement@jtcohen6 how would you feel about us enabling all of these: Already working: dbt ls -s dim_customers # fqn
dbt ls -s dim_customers.v1 # fqn
dbt ls -s dim_customers.v2 # fqn
dbt ls -s dim_customers.v3 # fqn
dbt ls -s dim_customers_v1.sql # file
dbt ls -s dim_customers_v2.sql # file
dbt ls -s dim_customers.sql # file and newly proposed: dbt ls -s dim_customers_v1 # file
dbt ls -s dim_customers_v2 # file but not enable this one? dbt ls -s dim_customers_v3 # alias I'd feel comfortable with the above, but want to double-check with you. |
Yeah this could be a place where it's time to teach people about I like your workaround as long as this sort of thing is already prevented: versions:
- v: 1
implemented_in: dim_customers_v2.sql #woke up and chose violence With two models in different directories There's now two file names that are dim_customers_v2, but they create different node names so I don't think anything would care up to now? I haven't tested this |
@joellabes I think we would be okay with allowing this rather than doing extra work to prevent it: models:
- name: dim_customers
latest_version: 3
versions:
- v: 3
- v: 2
defined_in: dim_customers_v1 # no .sql extension here
- v: 1
defined_in: dim_customers_v2 # `defined_in` rather than `implemented_in` And I think we'd want the output to look like this (which it does currently):
You can actually try this out right now by adopting the YAML above and then doing the following: dbt ls -s dim_customers_v1.sql |
@dbeatty10 I buy what you're proposing above! Let's add it to the multi-project epic. |
Acceptance criteriaSuppose the user has a models directory with files for versions
Then each of these should select one node each: dbt ls -s dim_customers_v1 # file
dbt ls -s dim_customers_v2 # file But this should not select any nodes: dbt ls -s dim_customers_v3 # alias Other resources |
Is this your first time submitting a feature request?
Describe the feature
Triggered by dbt-labs/docs.getdbt.com#3316
Describe alternatives you've considered
Staying strong with the dots, which are technically more correct but aren't something most people interact with unless they poke around in dbt's artifacts
Who will this benefit?
No response
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: