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 command: dbt ls #467

Closed
drewbanin opened this issue Jun 22, 2017 · 2 comments · Fixed by #1436
Closed

new command: dbt ls #467

drewbanin opened this issue Jun 22, 2017 · 2 comments · Fixed by #1436
Assignees
Labels
enhancement New feature or request

Comments

@drewbanin
Copy link
Contributor

drewbanin commented Jun 22, 2017

List models selected by CLI args. Eg.

$ dbt ls --models salesforce.* --exclude salesforce_accounts
models/salesforce/salesforce_users.sql
models/salesforce/salesforce_contacts.sql
models/salesforce/salesforce_leads.sql
....

This will be especially valuable when dbt supports selecting models by tags, materialization type, etc, etc.

Great idea @emilielimaburke

@clrcrl
Copy link
Contributor

clrcrl commented Mar 12, 2019

I think I'd prefer the command to be list as opposed to ls, and for it to just return the model names.

$ dbt list --models salesforce.* --exclude salesforce_accounts
salesforce_users
salesforce_contacts
salesforce_leads
....

Maybe it could have a flag like --verbose that shows the fqn versions:

$ dbt list --models salesforce.* --exclude salesforce_accounts --verbose
salesforce.salesforce_users
salesforce.salesforce_contacts
salesforce.salesforce_leads
....

I personally am less interested in the file paths, especially since the file paths don't include the name of my own project.

I'm not sure what the ordering of the output should be. Probably alphabetical? But I can also imagine someone might want to see them in the order they appear in the DAG, but that gets tricky.

@drewbanin
Copy link
Contributor Author

drewbanin commented Apr 30, 2019

Really nice spec here, @clrcrl! Let's do it!

$ dbt list 
  --resource_type {model|source|...|default|all}
  --select {list of selectors}
  --exclude {list of selectors}
  --output {json|name|path|selector}

Available resource types:

  • default:
    • model
    • archive
    • seed
    • test
    • source
  • all:
    • default+
    • documentation
    • analyses
    • macros

Resource type labels:

  • default
  • all
  • refable (everything in default except tests)

DEFAULTS:

  • resource_type = default
  • output = selector

OUTPUTS:

  • For name/path/selector, sort alphabetically
  • For json, use a dictionary indexed by node unique_id... sorting is not applicable. Assume output will be consumed programmatically

CAVEATS:

  • The path output should return file paths to resources relative to the cwd
  • The json output should return serialized ParseNodes (possibly a subset... we care about package name, tags, configs, depends_on, etc.... we care less about sql text). TBD if we normalize the json output across resource types... it's ok if these vary
  • Provide a (hidden?) ls alias for list (is that ok?)
  • If no resources are matched, exit with an error code (+ emit a warning?)
  • We need to be conscious about the stdout here... supress the logger, push warnings to stderr, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants