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 best practices concept in the Data Engineering pillar.
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 best practices concept in the Data Engineering pillar.
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 foundations concept in the Data Engineering pillar.
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 advanced techniques concept in the Data Engineering pillar.
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 advanced techniques concept in the Data Engineering pillar.
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 architecture concept in the Data Engineering pillar.
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