Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 38/ 160
02. SQL & Data Engineering Basics

ETL vs ELT Pipelines

Choose transform-before-load vs load-then-transform patterns for modern lakehouses.

IntermediateETL · ELT3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

ETL cleans data before storing it; ELT stores the raw data first and cleans it inside the data warehouse afterwards.

Think of it like…

ETL is washing and chopping vegetables in a prep kitchen before delivering them to the restaurant. ELT is delivering the whole crates to the restaurant's big kitchen and preparing dishes there on demand, keeping the original crates in case the recipe changes.

Where you’ve seen it

A subscription business loads Stripe and application data into BigQuery every hour with a managed connector (the EL), keeping raw tables untouched. dbt models transform them: staging models rename and cast, an intermediate model matches payments to subscriptions, and marts publish fct_subscription_months. When finance changes how refunds are treated, the team edits one model and rebuilds history from raw data; under the old ETL approach the raw detail had been discarded and a backfill was impossible.

Words you’ll hear

ELT
Load raw data first, then transform inside the warehouse with SQL.
Idempotent job
Running it twice with the same inputs produces the same result, with no duplicates.
Incremental load
Processing only new or changed rows instead of reloading everything.
Backfill
Recomputing history after a logic change or a missed run.

Visual diagram

Loading interactive diagram

Theory & deep dive

ETL vs ELT: when each fits

ETL made sense when warehouses were expensive and rigid: transform in a separate engine, load only what was needed. ELT fits cloud warehouses with elastic compute and cheap storage: load first, transform with SQL where the data lives, keep history, and let analysts contribute through SQL and version control. It makes iteration fast (change a model and rebuild) and preserves flexibility for new questions.

ETL is still right in specific cases: masking or removing sensitive data before it lands (PII, regulated fields), heavy non-SQL transformations (images, text parsing, ML inference), stream processing with low-latency transformations (Kafka, Flink, Spark Structured Streaming), and legacy targets that can't transform. Many teams mix: light cleaning and privacy controls on ingestion, business logic in the warehouse.

Privacy at the edge

Customer emails are hashed in the extraction step (an ETL-style transform) before loading, so raw PII never reaches the analytics warehouse, while all business logic (joins, metrics, features) runs later in SQL models.

Key takeaway: ELT by default for analytics; transform early only for privacy, non-SQL work or streaming.

Reliable pipelines: incremental, idempotent, tested

Incremental loads use a watermark (updated_at > last_run) or CDC to process only new data, with merge/upsert logic so reprocessing doesn't duplicate rows. Design jobs to be idempotent: delete-and-insert a partition or use MERGE on a key, so retries and backfills are safe. Handle late-arriving data with a lookback window, and store the load timestamp on every row. Keep raw data append-only and immutable.

Add tests at each layer: schema and type checks on ingestion; uniqueness and not-null on keys; relationships between facts and dimensions; accepted values for statuses; reconciliation of totals against source systems; and freshness alerts when a source stops updating. Orchestrate with explicit dependencies, retries and alerts. For data scientists: pin training data to a snapshot or a model version, version feature SQL in git, record the data as-of time, and avoid one-off notebook transformations that production can't reproduce.

An idempotent daily load

DELETE FROM mart.daily_revenue WHERE day = :run_date; INSERT INTO mart.daily_revenue SELECT day, SUM(amount) FROM stg.orders WHERE day = :run_date GROUP BY day; inside one transaction, so rerunning the same date yields the same rows.

Key takeaway: Incremental plus idempotent plus tested: retries and backfills become routine.

How it works, step by step

Step 1 of 4
Extract + load

1. Land raw data unchanged

Use connectors or CDC to copy source tables into raw warehouse tables, adding load timestamps.

raw.orders (append-only)
Key numbers at this step
Keep
the original

When to use it & trade-offs

What it is

ETL (extract, transform, load) cleans and reshapes data before loading it into the destination, usually in a separate processing engine. ELT (extract, load, transform) loads raw data into the warehouse or lakehouse first and transforms it there with SQL, using the destination's elastic compute. Cheap cloud storage and fast warehouses made ELT the default for analytics: keep an untouched raw copy, then build staging → intermediate → mart models (often with dbt), scheduled and monitored by an orchestrator such as Airflow, Dagster or Prefect.

Why it matters: Data scientists consume the output of these pipelines and increasingly contribute to them, since feature tables and training sets are pipeline products. Knowing the patterns (incremental loads, idempotency, CDC, data tests, backfills) explains why numbers change after a rerun, how to make your own work reproducible, and where to fix a data issue (at the source, in a model, or in your notebook).

When to reach for it

  • Warehouse models for reporting and ML features
  • Hourly or daily incremental ingestion
  • Reprocessing history after logic changes

When to avoid or be careful

  • Discarding raw data after transforming
  • Non-idempotent jobs that duplicate rows on retry
  • Notebook-only transformations that production can't rerun

ETL vs ELT

ELT (load, then transform in the warehouse)
Best for: Analytics on cloud warehouses and lakehouses

Strengths: Raw history kept; fast iteration; SQL-friendly.

Watch out: Raw sensitive data lands in the warehouse unless masked first.

ETL (transform before load)
Best for: Privacy filtering, non-SQL processing, legacy targets

Strengths: Smaller, cleaner loads; PII removed early.

Watch out: Raw detail may be lost; changes need pipeline rewrites.

Streaming transforms
Best for: Low-latency use cases

Strengths: Seconds of latency.

Watch out: More complex to build and operate.

Interview signals & numbers to know

When this topic comes up

  • “ETL or ELT?”
  • “Numbers changed after the pipeline reran”
  • “We need to backfill after changing a definition”
  • dbt and Airflow
  • CDC

Benchmarks & rules of thumb

EL + T -
ELT in two steps
MERGE / delete-insert -
idempotent write patterns
lookback window -
covers late-arriving data

Common mistakes & follow-ups

Common interview mistakes

  • Appending daily loads without deduplication, doubling rows after a retry.
  • Transforming away raw fields and later being unable to answer a new question.
  • Building training data in a notebook that can't be reproduced in production.

Likely interviewer follow-ups

  • When would you choose ETL over ELT?
  • How do you make a pipeline idempotent?
  • How do you test data quality in a pipeline?
Interview tip: Mention keeping raw data and making jobs idempotent. Those two principles solve most pipeline pain, and interviewers look for them.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply ETL vs ELT Pipelines with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
Star & Snowflake Schema Modeling
Next topic
NoSQL Databases (MongoDB Basics)