Working with dbt for a while, one can start to develop workflows that are really useful. It would be great to collect these somewhere, so that beginner dbt-ers can benefit from those experiences.
Here is my tip:
When I was really into R, I would use the beepr package all the time because then I could switch onto a new task without losing site of my priority. Many moons ago, I asked about a built-in dbt beep and Drew taught me the dbt run .. && say beep.
What is something you have in your workflow that might make it easier for someone to work in/around dbt?
Drew, do you think this approach could be used in a CI framework to only build/test/deploy only the models changed by the commits being merged into master?
Iβm imagining diffing the feature branch against master and only running those models (with @ and +) in production. Could speed up build/test/deploy times a lot by leaving out the models that arenβt affected.
Cool idea! This would definitely be a good starting point, but it wonβt hold up for changes to macros or dbt_project.yml, for instance. dbt doesnβt currently provide a rock-solid way of understanding which models are impacted by changes to a given set of files, but thatβs certainly something it could do some day!
Thatβs neat! I noticed that this does not run newly added models, so I modified the code to include all modified and newly created (but not yet commited) models.
function dbt_run_changed() {
children=$1
models=$(git status --short | grep -E '^( M|\?\?).*\.sql$' | awk '{print $2}' | xargs -n 1 basename | sed "s/\.sql$/${children}/g"| tr '\n' ' ')
echo "Running models: ${models}"
dbt run --models $models
}
This function takes an optional argument, +, that will also run the children of the changed models!