SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
  • Batch vs Stream Processing
  • Change Data Capture (CDC)
  • MapReduce
  • ETL Pipelines
  • Data Lakes
  • Data Warehousing
  • Data Lakehouse
  • Lambda Architecture
  • Kappa Architecture
  • Streaming Engines
  • Spark and Hadoop
  • Workflow Orchestration (Airflow)
  • Parquet and Columnar File Formats
  • Data Governance and Feature Stores
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Advanced Data Topics/Big Data Processing

ETL Pipelines

Extract data from sources, transform it, and load it where it can be analysed.

⏱ 12 min readBeginnerHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

An ETL pipeline moves data from where it is made to where it can be analysed. ETL stands for Extract, Transform, Load.

  • Extract: read the data from its sources (databases, files, APIs).
  • Transform: clean it, fix it, join it and reshape it so it can be trusted.
  • Load: write the result into a data warehouse or data lake, where people and tools can query it.

02Concept: What is it?

Business data starts out messy and scattered. Orders are in one database, customers in another, payments come as files from a partner, and clicks arrive from an app. Each source uses its own formats, spellings and rules. A report that needs all of them cannot be built until the data is gathered, cleaned and put in one place. That is the job of an ETL pipeline.

The usual order is Extract, then Transform, then Load. Transform means things like removing duplicates, rejecting broken rows, making dates look the same, turning euros into dollars and joining tables. The transform usually runs on a separate processing server or cluster, so the warehouse receives only finished, tidy rows.

ETL
πŸ—„οΈSourcesdatabases, files, APIs
→↓extract
🧹Transformclean, join, reshape
→↓load
🏒Warehousetidy tables
→↓
πŸ“ŠReports
The data is cleaned before it reaches the warehouse.

Modern cloud warehouses are fast and cheap at storing and processing data. So many teams switched the last two steps and use ELT: load the raw data first, then transform it inside the warehouse with SQL. The raw copy stays, so a transform can be changed and run again.

ELT
πŸ—„οΈSources
→↓extract
πŸ“₯Load rawas it is
→↓transform in SQL
🏒Warehouseraw + clean tables
→↓
πŸ“ŠReports
The warehouse does the transform. The raw data is kept.
🧠ETL or ELT?
The only difference is where and when the cleaning happens. ETL cleans before loading. ELT loads first and cleans inside the destination. Both are pipelines with the same three jobs.

03Real-Life Example

🍡The Kitchen Delivery Truck
A restaurant gets food from many farms. A truck goes round and collects the boxes (extract). At the kitchen door, staff wash the vegetables, throw away the bad ones, cut things to the same size and label them (transform). Then everything is put on the shelves in the pantry in an order the cooks understand (load). Cooks never see mud or rotten fruit. In the ELT version, the truck puts the boxes straight on a big shelf, and the washing and cutting is done later in the kitchen, so the raw boxes are still there if a recipe changes.
Kitchen
ETL pipeline
Farms
Source systems (databases, files, APIs)
The truck collecting boxes
Extract
Washing, sorting, cutting
Transform (clean, validate, join)
Throwing away rotten items
Rejecting invalid rows, with a reason
Shelving in the pantry
Load into the warehouse
The cooks
Analysts and dashboards
A schedule: truck comes every night
A nightly batch run
Keeping raw boxes in the cold room
ELT: a raw table kept for re-processing
One bad row, followed through
πŸ“„Raw row" ana lopez ", 03/02/2024, EUR
→↓tidy name
βœ‚οΈAna Lopez
→↓fix date
πŸ“…2024-03-02
→↓to USD
πŸ’΅Clean rowready to load

04Why Do We Need It?

🧩One place for all data
Join orders, customers and clicks from different systems into one view.
🧼Trustworthy numbers
Duplicates, missing values and mixed currencies are fixed once, not in every report.
πŸ›‘οΈProtect the live system
Analysts query the warehouse, not the busy production database.
πŸ“One definition
What counts as an active user or revenue is written once, in the pipeline.
πŸ•°οΈHistory
The warehouse keeps data from the past, even if the source overwrites it.
πŸ€–Ready for analytics and ML
Clean, structured data feeds dashboards and models.
Source systems are built to run the business. Pipelines turn their data into something you can analyse.

05Where Do We Use It?

πŸ“ŠBusiness intelligence
Daily sales, finance and operations dashboards.
🏒Data warehouses
Loading cleaned tables into a warehouse such as Snowflake, BigQuery or Redshift.
🌊Data lakes
Landing raw files, then preparing them for use.
πŸ€–Machine learning
Preparing the features and training sets for models.
πŸ”„System migration
Moving data from an old system to a new one, with fixes on the way.
πŸ“‹Reports for regulators
Repeatable, checked data sets for audits.

06Types / Parts / How It Works

The three steps in more detail

StepTypical workWhat can go wrong
ExtractFull copy, or only what changed (incremental, or Change Data Capture)Load on the source, missed changes, API limits, schema changes
TransformDedupe, validate, standardise formats, convert units, join, aggregateWrong rules, silent data loss, slow jobs
LoadAppend, upsert or replace into warehouse tablesDuplicate loads, half-finished loads, locked tables

ETL vs ELT

ETLELT
Where the transform runsOn a separate processing server or clusterInside the warehouse or lake
What is loadedOnly finished rowsRaw rows first, then derived tables
Raw data kept?Usually notYes, so you can re-run with new rules
Best whenData must be cleaned or masked before it may be stored; limited warehouse powerA strong cloud warehouse and a wish for flexibility
SkillsPipeline code or ETL toolsSQL and tools such as dbt

How runs are triggered

StyleHow it worksGood for
Scheduled batchRun at set times, for example every nightReports that can be a day old
Micro-batchRun every few minutes on small chunksFresher data without a full stream
IncrementalLoad only the new or changed rows since the last runLarge tables
StreamingProcess each change as it arrives (often fed by CDC)Dashboards that must be seconds old
A pipeline is a chain of tasks
1️⃣Extract orders
→↓
2️⃣Validate
→↓
3️⃣Join customers
→↓
4️⃣Load
→↓
5️⃣Check counts
Extract Transform Load Check
Orchestrators such as Airflow run the tasks in order, retry failures and send alerts.
VisualizerClean rows, and where the cleaning runsStart with every rule off and see the messy data loaded. Turn on the rules one by one and watch the problems and the revenue total change. Then switch between ETL and ELT and push the data size up.
Where does the transform step run?

A separate server cleans the rows. Only the finished rows reach the warehouse.

Extract: source rows (8)
#1 | " ana lopez " | 120.50 USD | 2024-03-01
#2 | "Ben Ito" | 99 EUR | 03/02/2024
#3 | "Cara Mills" | (empty) USD | 2024-03-02
#2 | "Ben Ito" | 99 EUR | 03/02/2024
#5 | "dev PATEL" | 45.00 USD | 2024-03-03
#6 | "Eli Ross" | 300 EUR | 03/04/2024
#7 | "Fay Chen" | 75.25 USD | 2024-03-04
#8 | "Gus Webb" | n/a USD | 2024-03-05
Load: warehouse table (8)
#1 | " ana lopez " | 120.50 USD | 2024-03-01
#2 | "Ben Ito" | 99 EUR | 03/02/2024
#3 | "Cara Mills" | (empty) USD | 2024-03-02
#2 | "Ben Ito" | 99 EUR | 03/02/2024
#5 | "dev PATEL" | 45.00 USD | 2024-03-03
#6 | "Eli Ross" | 300 EUR | 03/04/2024
#7 | "Fay Chen" | 75.25 USD | 2024-03-04
#8 | "Gus Webb" | n/a USD | 2024-03-05
Rows loaded
8
of 8 extracted
Rows rejected
0
with a reason
Problems left
11
in loaded data
Revenue total
738.75
mixes EUR and USD
Transform time
2.5 h
fits the 4 h window
With no rules, all 8 messy rows are loaded as they are: 11 problems end up in the warehouse. Reports on this data would double-count Ben and add dollars to euros.

The rows and the example rate (1.1) are made up. The speeds (40 and 200 million rows per hour) are illustrative, only to show that one transform server can run out of time while a scaled-out warehouse engine often does not. Real speeds depend on your tools and data.

07How to Use It / Steps / Implementation

Building a pipeline you can trust

  1. 1
    Know the question first
    Start from the report or model that needs the data. It tells you which sources and which fields matter.
  2. 2
    Extract only what you need
    Prefer incremental extracts (changed rows only) or CDC for big tables. A full copy every night does not scale.
  3. 3
    Land the raw data
    Keep an untouched copy, at least for a while. It lets you fix a bug in a rule and run again.
  4. 4
    Write the rules down as code
    Dedupe, validate, standardise. Put rules in version control, with tests on small sample data.
  5. 5
    Reject with a reason, do not drop silently
    Send bad rows to a quarantine table with the reason, so someone can fix the source or the rule.
  6. 6
    Make loads idempotent
    Running the same load twice must not create duplicate rows. Use upserts, or replace one partition at a time.
  7. 7
    Check the result
    Compare row counts, totals and nulls with the source. Fail the run loudly if the numbers look wrong.
  8. 8
    Use an orchestrator
    A tool such as Airflow handles schedule, order of tasks, retries and alerts, and lets you re-run just one day.
πŸ’‘Re-run safely
Design every task so that running it again for the same day gives the same result. Then fixing a bug is simple: correct the rule, re-run the day.
⚠️Do not move secrets and personal data carelessly
Mask or drop sensitive fields as early as the rules allow, and control who can read the raw zone. A pipeline copies data, and every copy needs protection.

08Key Terms to Know

TermMeaning in easy words
ETLExtract, Transform, Load: clean the data before loading it
ELTExtract, Load, Transform: load raw data first, transform inside the destination
Source systemWhere the data is created, such as an app database
Data warehouseA database designed for analysis and reports
Staging areaA temporary place where extracted data waits before it is transformed
Incremental loadLoading only the rows that are new or changed since the last run
Idempotent loadA load that gives the same result if it is run twice
OrchestratorA tool (such as Airflow) that schedules and monitors pipeline tasks
Data quality checkA test on the data, for example row counts, nulls or allowed values
Quarantine tableA place for rejected rows, kept with the reason for the rejection
BackfillRe-running a pipeline over past days, for example after fixing a rule

09Pros, Cons and Trade-offs

βœ… Pros
  • One clean, trusted source for reports
  • Analytics do not slow down the live system
  • Rules are written once and reused
  • History is kept in the warehouse
  • Easy to add new reports on top
  • Repeatable and testable when written as code
⚠️ Cons
  • Data is late: it is only as fresh as the last run
  • Pipelines break when a source changes its format
  • Hard to debug when many steps hide a wrong number
  • A transform bug can quietly spread bad data
  • Copying data raises storage and privacy concerns
  • Needs ongoing care: monitoring, retries, ownership

Trade-offs

ChoiceWe gainWe lose
ETL (clean before load)A tidy warehouse, sensitive fields can be removed earlyThe raw data is gone, and the transform server must keep up
ELT (clean after load)Raw data kept, SQL-based, scales with the warehouseThe warehouse holds messy data, so access and cost need care
Full extractSimple and completeSlow and heavy as data grows
Incremental extractFast and lightMisses deletes and late changes unless handled with care
Nightly batchSimple and cheapData is up to a day old
StreamingData is seconds oldMore complex to build and run

10Common Problems and Mistakes

Common mistakes

  1. Silent data loss. A join or filter quietly drops rows, and nobody notices until a number is wrong.
  2. Duplicate loads. A retry loads the same day twice and the totals double.
  3. Mixed units. Adding euros to dollars, or local times to UTC, gives answers that look fine and are wrong.
  4. No checks. The job finishes with "success" even though it loaded zero rows.
  5. Hard-coded rules. Business rules buried in scripts that nobody can read or test.
  6. Relying on updated_at. Deletes are never seen, and rows changed by scripts that forget the timestamp are missed.
  7. Throwing away the raw data. After a rule bug there is nothing to re-process, so you go back to the source, which may have changed.

Things to watch

🧬Schema changes
A source renames or removes a column and the pipeline fails or loads nulls.
⏱️Late runs
A job that now takes longer than its time window delays every report.
πŸ“‰Data drift
Values slowly change shape, for example a new status code, and break a rule.
πŸ”Sensitive data
Personal data copied into the warehouse needs masking and access control.

11Real-World Examples

🌬️Orchestration with Airflow
Apache Airflow is widely used to schedule and monitor pipeline tasks.
🧱dbt and ELT
dbt runs SQL transforms inside the warehouse, a common ELT setup.
☁️Cloud warehouses
Snowflake, BigQuery and Redshift make loading first and transforming later practical.
πŸ”ŒConnectors
Tools such as Fivetran and Airbyte copy data from common sources into a warehouse.
⚑Spark jobs
Large transforms often run on a Spark cluster in the ETL style.
πŸ›’Retail reporting
Sales, stock and web data are gathered nightly so managers see one report each morning.
πŸ“Note
Tool names and features change quickly. The ideas here (extract, transform, load, idempotent runs, quality checks) stay the same.
Mini case: a nightly sales report
πŸ—„οΈOrders DB
→↓changed rows
πŸ“₯Raw zonekept 30 days
→↓clean + join
🏒Warehousesales table
→↓
πŸ“ŠDashboardready at 8 a.m.
The pipeline runs at 1 a.m. so the report is ready when the team arrives.

12Related Topics to Read Next

Data Warehousing→

The usual destination of an ETL pipeline.

Data Lakes→

Where raw data often lands first in an ELT setup.

Change Data Capture (CDC)β†’

A light way to extract only what changed.

Batch vs Stream Processing→

Decides how often the pipeline runs.

Data Lakehouse→

Combines lake storage with warehouse tables.

MapReduce→

The classic model behind big parallel transforms.

Idempotency→

Makes it safe to re-run a load.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”ETL: Extract, Transform, Load: gather, clean, store for analysis.
  • βœ”ELT: load raw first, transform inside the warehouse. Raw data is kept.
  • βœ”Extract: prefer incremental or CDC over full copies for big tables.
  • βœ”Transform: dedupe, validate, standardise, join. Quarantine rejects with a reason.
  • βœ”Load: idempotent (upsert or replace a partition), never blind append.
  • βœ”Checks: row counts, nulls, freshness, totals. Fail loudly.
  • βœ”Run: an orchestrator (Airflow) for schedule, retries, backfills.
  • βœ”One line: β€œGather it, clean it, put it where people can use it, and be able to run it again.”
← Previous
MapReduce
Next β†’
Data Lakes