Building Resilient Data Pipelines with Spark and dbt
Try This First
Test your knowledge before reading. Don't worry if you get it wrong — that's part of learning.
Key Insights
- Combine Spark's processing power with dbt's transformation layer to build production-grade, tested, documented data pipelines.
Architecture: Spark + dbt
The modern data stack combines Spark for heavy ETL processing with dbt for SQL-based transformations, testing, and documentation:
- Spark — ingestion, heavy computation, ML feature engineering
- dbt — business logic transformations, data quality tests, documentation
- Orchestration — Dagster/Airflow coordinates Spark jobs → dbt runs
# Spark: heavy lifting (ingestion, joins, aggregation)
# dbt/models/staging/stg_transactions.sql
WITH source AS (
SELECT * FROM {{ source('raw', 'transactions') }}
),
cleaned AS (
SELECT
transaction_id,
customer_id,
CAST(amount AS DECIMAL(18,2)) AS amount,
UPPER(currency) AS currency,
DATE(transaction_ts) AS transaction_date,
CASE
WHEN amount > 10000 THEN 'high_value'
WHEN amount > 1000 THEN 'medium'
ELSE 'standard'
END AS value_tier
FROM source
WHERE transaction_id IS NOT NULL
)
SELECT * FROM cleanedData Quality Tests
dbt tests validate your data at every transformation step:
# dbt/models/staging/schema.yml
version: 2
models:
- name: stg_transactions
columns:
- name: transaction_id
tests:
- unique
- not_null
- name: amount
tests:
- not_null
- dbt_utils.accepted_range:
min_value: 0
max_value: 10000000
- name: currency
tests:
- accepted_values:
values: ['USD', 'EUR', 'GBP', 'JPY']Lineage and Documentation
dbt auto-generates lineage graphs and documentation. Combined with Spark's execution plans, you get end-to-end visibility:
- Column-level lineage — trace any metric back to its raw source
- Impact analysis — understand downstream effects of schema changes
- Run history — track freshness, execution time, and test results
Article Metadata
Review with Spaced Repetition
Add this lesson's 3 flashcards to your SM-2 study queue. They will appear when due in the Study Queue.
Feynman Concept Cards
Master each building block: read the ELI5, explore the analogy, work the example, find your gaps, teach it back, build it.
Data Quality is a concept in best practices. In simple terms, Data Quality covers best practices in Data Engineering. This data engineering concept addresses key topics in the best practices in data engineering domain. Also known as: data observability, data val
Analogy
Example
Find Gaps
Explain Data Quality as if teaching a colleague who is new to best practices. Cover: what it is, how it works, and why it matters.
Create
Create a checklist that demonstrates Data Quality in a real-world best practices scenario. Walk through your design decisions.
Show solution
A checklist for Data Quality should include: 1. The core components of data quality 2. How they interact 3. Expected outcomes or outputs
DataOps is a concept in best practices. In simple terms, DataOps covers best practices in Data Engineering. This data engineering concept addresses key topics in the best practices in data engineering domain. Also known as: DataOps practices, data operation
Analogy
Example
Find Gaps
Explain DataOps as if teaching a colleague who is new to best practices. Cover: what it is, how it works, and why it matters.
Create
Create a checklist that demonstrates DataOps in a real-world best practices scenario. Walk through your design decisions.
Show solution
A checklist for DataOps should include: 1. The core components of dataops 2. How they interact 3. Expected outcomes or outputs
Extract-Transform-Load is a concept in foundations. In simple terms, Extract-Transform-Load covers foundational knowledge in Data Engineering. This data engineering concept addresses key topics in the foundational knowledge in data engineering domain. Also known as: ET
Analogy
Example
Find Gaps
Explain Extract-Transform-Load as if teaching a colleague who is new to foundations. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Extract-Transform-Load in a real-world foundations scenario. Walk through your design decisions.
Show solution
A diagram for Extract-Transform-Load should include: 1. The core components of etl 2. How they interact 3. Expected outcomes or outputs
Dagster Orchestrator is a concept in advanced techniques. In simple terms, Dagster Orchestrator covers advanced techniques in Data Engineering. This data engineering concept addresses key topics in the advanced techniques in data engineering domain. Also known as: dagster. R
Analogy
Example
Find Gaps
Explain Dagster Orchestrator as if teaching a colleague who is new to advanced techniques. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Dagster Orchestrator in a real-world advanced techniques scenario. Walk through your design decisions.
Show solution
A diagram for Dagster Orchestrator should include: 1. The core components of dagster 2. How they interact 3. Expected outcomes or outputs
ML Pipeline Engineering is a concept in advanced techniques. In simple terms, ML Pipeline Engineering covers advanced techniques in Data Engineering. This data engineering concept addresses key topics in the advanced techniques in data engineering domain. Also known as: MLOps,
Analogy
Example
Find Gaps
Explain ML Pipeline Engineering as if teaching a colleague who is new to advanced techniques. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates ML Pipeline Engineering in a real-world advanced techniques scenario. Walk through your design decisions.
Show solution
A diagram for ML Pipeline Engineering should include: 1. The core components of ml pipeline 2. How they interact 3. Expected outcomes or outputs
Feature Store is a concept in architecture. In simple terms, Feature Store covers architectural patterns for Data Engineering. This data engineering concept addresses key topics in the architectural patterns for data engineering domain. Also known as: ML featur
Analogy
Example
Find Gaps
Explain Feature Store as if teaching a colleague who is new to architecture. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Feature Store in a real-world architecture scenario. Walk through your design decisions.
Show solution
A diagram for Feature Store should include: 1. The core components of feature store 2. How they interact 3. Expected outcomes or outputs
Feynman Synthesis — Prove You Understand
1. The One-Pager
Explain this lesson's core idea to a smart 15-year-old. No jargon allowed.
2. The Gap Map
List 3 things you are still unsure about. Be specific.
Knowledge Check
Test your understanding of this lesson.
Flashcards
Space = flip · 1-4 = grade · Swipe on mobile