📘 Introduction

In this hands-on dbt tutorial, we’ll walk you step-by-step through how to use the dbt retry command to efficiently re-run only failed models after a broken dbt run. Instead of re-executing your entire DAG, you can save time and resources by retrying only what’s necessary.

📌 This is a must-know topic for the dbt Analytics Engineering Certification Exam, so mastering it now puts you one step closer to passing the exam and leveling up your data engineering skills! 👨‍🎓

✅ Prerequisites

☑️ A dbt project set up
☑️ Existing dbt models defined in your models/ directory

💡 What is the dbt retry command?

The dbt retry command allows you to:

  • Re-run only the models that failed in your previous dbt run
  • Automatically skip successful models to save time
  • Continue building your DAG from the point of failure without starting over
💡
This is especially useful when working with large dbt projects where re-running everything would be slow and costly.

Let’s walk through a real scenario where dbt retry becomes your best friend.

🧪1️⃣ Existing dbt models in your dbt project

We’ve already created some dbt models in our project.

The data linage of our project looks as follows:

🚀2️⃣ Run models

Let’s run our project with:

dbt run

But we encounter an error. The model transformed_course_mapping fails, and because of that, its downstream dependency dim_courses also fails to run.

All other models that do not depend on the broken model execute successfully.

🛠️3️⃣ Fix Bug

Looking at the error, the issue is with a column name. The query used a column names that doesn’t exist. The correct name isname. So let's open the model and rename the column:

SELECT DISTINCT
    code,
    name,
    source_name
FROM {{ ref("cleaned_course_mapping") }}

🔄4️⃣ Use dbt retry

Now instead of re-running the entire DAG, we can run:

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In