SQL for Data Pipelines: Incremental Loads, CDC & Watermarks
Data pipelines move and transform data from source systems to destinations like data warehouses
and lakes. Incremental loads process only new or changed data, making pipelines efficient and
scalable. This guide covers ETL, ELT, CDC, watermarks, upserts, idempotency, staging areas, and
the 25 interview questions that actually come up — with deep, descriptive theory aligned to the
topic.
25 Interview QuestionsBeginner to AdvancedETL, ELT, CDC, Data EngineeringUpdated Dec 3, 2026
KW
Kailas Warade
✓ Verified Author
Data Engineer · Oracle Certified · SQL & PL/SQL
Kailas works with SQL, PL/SQL, Python, and PySpark to build data pipelines.
He writes the SQL interview guides at Sankalan Data Tech, focused on
practical, real-world answers.
🏆 Oracle Certified💼 Data Engineer📝 SQL & PL/SQL Guides📍 Pune, India
Data pipelines are the backbone of modern data engineering. They automate the movement of
data, ensuring that analytical systems have fresh, reliable data.
Pipelines can be batch (run periodically) or streaming (run continuously). The choice
depends on latency requirements and data volume.
SQL is central to data pipelines because most transformations happen in SQL, whether in
ETL tools, Spark, or cloud warehouses.
ETL vs ELT
ETL (Extract, Transform, Load) transforms data before loading. ELT (Extract, Load,
Transform) loads data first, then transforms it in the destination using SQL.
Aspect
ETL
ELT
Transform timing
Before load
After load
Transform location
Staging area / ETL tool
Destination (warehouse)
Best for
Complex transformations
Cloud warehouses with SQL power
ELT is more common in modern cloud data stacks because cloud warehouses have powerful SQL
engines that can handle transformations at scale.
The choice depends on where the transformation power is — in the ETL tool or in the
warehouse.
Incremental Loads in Depth
An incremental load processes only new or changed data since the last run, rather than
reloading everything.
-- Full load: process everything
SELECT * FROM source_table;
-- Incremental load: process only new/changed
SELECT * FROM source_table
WHERE updated_at > :last_processed_timestamp;
Incremental loads are more efficient than full loads because they process less data. This
reduces cost, time, and load on source systems.
The key to incremental loads is identifying what changed. This is done through watermarks,
CDC, or change tracking.
Incremental loads are the default pattern in modern data engineering because they scale.
CDC in Depth
CDC (Change Data Capture) is a technique to capture changes (inserts, updates, deletes)
from a source database in real time or near-real time.
CDC is more powerful than watermark-based incremental loads because it captures deletes and
works in real time.
CDC is typically implemented using database logs (like MySQL binlog or PostgreSQL WAL) or
tools like Debezium.
CDC is essential for real-time data pipelines and keeping warehouses in sync with
operational databases.
Watermarks in Depth
A watermark is a high-water mark (like a timestamp or ID) that tracks the last processed
point, enabling incremental loads.
-- Watermark: last processed timestamp
SELECT MAX(updated_at) FROM target_table;
-- Next run: process only newer data
SELECT * FROM source_table
WHERE updated_at > :last_processed_timestamp;
Watermarks are simple and effective for append-only or slowly changing data. They are less
effective for deletes or out-of-order data.
Watermarks are stored in a control table and updated after each successful run.
Watermarks are the most common incremental load pattern because they are simple and
reliable.
Upserts and MERGE
An upsert is an operation that updates a row if it exists, or inserts it if it does not.
-- MERGE: upsert in one statement
MERGE INTO target_table t
USING source_table s
ON t.id = s.id
WHEN MATCHED THEN
UPDATE SET t.name = s.name, t.amount = s.amount
WHEN NOT MATCHED THEN
INSERT (id, name, amount)
VALUES (s.id, s.name, s.amount);
MERGE combines INSERT and UPDATE in one operation, making it ideal for incremental loads
where rows may be new or changed.
MERGE is supported in Oracle, SQL Server, and PostgreSQL (via INSERT ON CONFLICT). MySQL
uses INSERT ... ON DUPLICATE KEY UPDATE.
MERGE is the standard pattern for upserts in SQL.
Idempotency
Idempotency means running the same pipeline multiple times produces the same result.
-- Idempotent: same result every time
MERGE INTO target ... -- upsert is idempotent
-- Non-idempotent: duplicates on re-run
INSERT INTO target SELECT * FROM source; -- duplicates if re-run
Idempotency is critical for reliability and recovery. If a pipeline fails and re-runs, it
should not create duplicates or corrupt data.
MERGE and upserts are naturally idempotent. Plain INSERT is not.
Idempotency is a core principle of reliable data engineering.
25 SQL Data Pipelines Interview Questions and Answers
These are the data pipeline and incremental load questions that come up most often in data
engineering interviews. Every answer stands on its own — read them in any order, or work
through them in sequence to build a complete understanding of data pipelines, incremental
loads, CDC, watermarks, upserts, and idempotency.
/
🔍
No matching questions found
Try a keyword like ETL, CDC, watermark, or MERGE.
A data pipeline is a series of steps that moves and transforms data from source
systems to a destination, such as a data warehouse or lake.
Source → Extract → Transform → Load → Destination
Data pipelines automate the movement of data, ensuring that analytical systems have
fresh, reliable data.
Pipelines can be batch or streaming, depending on latency requirements.
ETL (Extract, Transform, Load) is a data pipeline pattern where data is extracted
from sources, transformed in a staging area, and loaded into a destination.
Extract → Transform → Load
ETL is the traditional pattern, where transformation happens before loading.
ETL is best for complex transformations that need a dedicated processing layer.
ELT (Extract, Load, Transform) is a data pipeline pattern where data is extracted
and loaded first, then transformed in the destination using SQL.
Extract → Load → Transform
ELT is more common in modern cloud data stacks because cloud warehouses have
powerful SQL engines.
ELT leverages the warehouse's compute power for transformations.
An incremental load processes only new or changed data since the last run, rather
than reloading everything.
SELECT * FROM source_table
WHERE updated_at > :last_processed_timestamp;
Incremental loads are more efficient than full loads because they process less data.
They are the default pattern in modern data engineering.
CDC (Change Data Capture) is a technique to capture changes (inserts, updates,
deletes) from a source database in real time or near-real time.
Data lineage is essential for debugging, compliance, and understanding data
quality.
Data lineage tools automatically capture this information.
A batch pipeline runs periodically on stored data. A streaming pipeline runs
continuously on real-time data.
Aspect
Batch
Streaming
Data
Finite, stored
Unbounded, continuous
Latency
Minutes to hours
Milliseconds to seconds
Use case
Reports, ETL
Fraud detection, monitoring
The choice depends on latency requirements.
A data quality check validates that data meets expectations before it moves to the
next stage.
-- Data quality check
SELECT COUNT(*) FROM staging WHERE amount IS NULL;
-- If count > 0, fail the pipeline
Data quality checks prevent bad data from propagating through the pipeline.
They are essential for reliable data pipelines.
A late-arriving record is data that arrives after the window or batch that should
have included it.
-- Late-arriving record
Event time: 2026-12-01
Arrival time: 2026-12-03 (late)
Late-arriving records are a common challenge in data pipelines. They require
reprocessing or special handling.
Watermarks and CDC help handle late-arriving records.
A slowly changing dimension (SCD) is a dimension whose attributes change over time.
In a pipeline, SCD handling determines how changes are loaded.
-- SCD Type 2: new row for each change
INSERT INTO dim_customer (customer_id, city, effective_date, is_current)
VALUES (101, 'Mumbai', '2026-12-03', true);
SCD handling is a key part of dimensional data pipelines.
SCD Type 2 is the most common approach for preserving history.
A data pipeline orchestration tool schedules and manages data pipelines, handling
dependencies, retries, and monitoring.
-- Orchestration tools
Apache Airflow, Dagster, Prefect, Azure Data Factory
Orchestration tools are essential for production data pipelines.
They handle scheduling, dependencies, retries, and alerting.
A retry strategy defines how a pipeline handles failures — how many times to retry,
with what delay.
-- Retry strategy
Retry 3 times with exponential backoff
Retry strategies are essential for reliable pipelines. They handle transient
failures like network issues.
Idempotency is required for safe retries.
A data pipeline monitoring strategy tracks pipeline health, data quality, and
freshness.
Monitoring is essential for production pipelines. It detects issues before they
impact downstream users.
Monitoring tools include Grafana, Datadog, and cloud-native monitoring.
A pipeline is a series of data processing steps. A workflow is a broader concept
that can include pipelines, approvals, and other tasks.
-- Pipeline: data processing steps
Extract → Transform → Load
-- Workflow: broader, includes pipelines
Pipeline → Approval → Notification
Pipelines are a subset of workflows. Workflows can include non-data tasks.
A pipeline is a linear or branching series of data processing steps. A DAG (Directed
Acyclic Graph) is a graph structure that represents dependencies between tasks.
-- DAG: task dependencies
Task A → Task B → Task C
Task A → Task D
DAGs are used in orchestration tools like Airflow to represent pipeline
dependencies.
DAGs enable complex, branching pipelines.
Well-designed data pipelines follow a few key principles.
Use incremental loads — for efficiency and scale.
Use watermarks or CDC — to track changes.
Use MERGE for upserts — for idempotency.
Include data quality checks — to prevent bad data propagation.
Use orchestration tools — for scheduling and reliability.
These principles produce a data pipeline that is efficient, reliable, and easy to
operate.
Mistakes I Keep Seeing in Interviews
These come up repeatedly. None of them are exotic, and every one of them is easy to avoid
once you know it is coming.
Mistake one: confusing ETL with ELT. Know the difference: transform before
vs after load.
Mistake two: not understanding incremental loads. This is the default
pattern in modern data engineering.
Mistake three: confusing watermark with CDC. Watermarks track a point;
CDC captures all changes including deletes.
Mistake four: not understanding idempotency. This is critical for reliable
pipelines and safe retries.
Mistake five: using plain INSERT for incremental loads. This causes
duplicates on re-run. Use MERGE instead.
Mistake six: not including data quality checks. Bad data propagates
through the pipeline and causes downstream issues.
Follow-Up Questions Interviewers Ask
Getting the first answer right is only half the interview. What usually decides the
outcome is what happens next. Here is what to prepare for on the data pipelines topic.
After “What is a data pipeline?” — expect
“What is ETL vs ELT?”
“What is an incremental load?”
“What is CDC?”
“What is a watermark?”
After “Incremental loads” — expect
“How do you track changes?”
“What is a watermark?”
“How do you handle deletes?”
“What is CDC?”
After “MERGE” — expect
“What is an upsert?”
“How does MERGE work?”
“What is idempotency?”
“When would you use MERGE vs INSERT?”
After “Data quality” — expect
“What checks would you include?”
“How do you handle failures?”
“What is a retry strategy?”
“How do you monitor pipelines?”
For every question above, prepare a second-level answer. The candidates who pass are not
the ones who memorized the first answer — they are the ones who kept going for another
thirty seconds and said something useful about why it matters.
Quick Quiz
Five questions to check whether the topics above have landed.
1. Which pattern transforms data before loading?
2. What tracks the last processed point in an incremental load?
3. Which SQL statement combines INSERT and UPDATE?
4. What does idempotency mean?
5. Which CDC capability makes it more powerful than watermark-based loads?