Interactive Lesson: dbt Testing

dbt Testing Interactive Exercise

🔍 dbt Testing Master Class

Learn to write comprehensive dbt tests for your data pipelines

🛒 E-Commerce Analytics Scenario

You’re a analytics engineer at ShopMart, an online retailer. Your team needs to ensure data quality for the analytics pipeline that powers business decisions. The warehouse contains orders, customers, and products data that must be tested for accuracy and freshness.

📊 Sample Data Structure:

orders table:
– order_id (primary key)
– customer_id (foreign key)
– order_date
– status (pending/completed/cancelled)
– total_amount

customers table:
– customer_id (primary key)
– email
– created_at
– tier (bronze/silver/gold)

daily_revenue view:
– date
– revenue
– order_count
✏️ Write Your dbt Test (YAML)
💡 Hint:

Start by adding ‘- not_null’ under the tests section for the column you want to test.

📋 Test Results & Feedback

Progress Tracker 0/6 Tests Completed

Current Challenge: Not Null Test

Ensure critical fields like order_id and customer_id are never null. This prevents incomplete records from corrupting your analytics.

Waiting for test…

Write your test configuration and click “Run Test” to see the results.

📚 Learning Resources

  • Each test type helps catch different data quality issues
  • Combine multiple tests for comprehensive coverage
  • Freshness tests are crucial for time-sensitive data
  • Volume tests help detect data pipeline failures