PicnicSupermarket / dbt-score

Linter for dbt metadata
https://dbt-score.picnic.tech
MIT License
80 stars 5 forks source link

Add lint option to only output models with score under some threshold #71

Open lhz opened 1 month ago

lhz commented 1 month ago

We are mostly interested in knowing which models are not up to standard, and that can be hard to glimpse when the project has many models and most of them already have a gold badge.

It would be very useful to have an option for the lint command that will cause it to only output models whose score is less than the first threshold (or perhaps more flexible, a custom threshold given as argument to the option.)

Related to this, it would also be useful to output only the rules that were not satisfied, but I'm unsure if that should be a separate option or a direct result of the one suggested.

jochemvandooren commented 1 month ago

Hey @lhz, thanks for opening this issue! I agree, this is something that needs to be added. We are planning to work on it soon, but you are of course welcome to contribute as well.

I think the most important features to include are:

These two options then can be combined to get: all models with all rules, all models showing only their failing rules, failing models with their failing rules and failing models with all their passing rules. (last option will probably never be used though :grin: )

japborst commented 3 weeks ago

As a workaround, you could also achieve this by using --format json and jq.

For a threshold that's e.g. 7.7:

dbt-score lint --format json | jq -r '.models | to_entries[] | select(.value.score < 7.7) | .key

or to get all failing models

dbt-score lint --format json | jq -r '.models | to_entries[] | select(.value.pass|not) | .key