Data Engineering Interview: Comprehensive Preparation Guide
Data engineering interviews test your ability to design, build, and maintain data systems at scale.
Interview Structure
What Interviews Assess:
- SQL proficiency
- System design thinking
- Data modeling skills
- Real-world problem-solving ability
Interview Stages:
| Stage | Format | Duration | Focus |
|---|---|---|---|
| Phone Screen | Behavioral + Basic Technical | 30-45 min | Communication, basic skills |
| Technical Screen | SQL/Python Coding | 45-60 min | Coding proficiency |
| System Design | Whiteboard/Document | 45-60 min | Architecture thinking |
| Behavioral | STAR Format | 30-45 min | Culture fit, leadership |
| Final Round | Mixed | 30-60 min | Cross-functional fit |
Key Insight: Data engineering interviews assess SQL proficiency, system design thinking, data modeling skills, and real-world problem-solving ability.
SQL Interview Questions
Question 1: Top-N per Group
-- Question: Find the top 3 customers by revenue in each region
-- Approach 1: ROW_NUMBER()
SELECT *
FROM (
SELECT
region,
customer_name,
total_revenue,
ROW_NUMBER() OVER (PARTITION BY region ORDER BY total_revenue DESC) AS rank
FROM customer_revenue
) ranked
WHERE rank <= 3;
-- Approach 2: DENSE_RANK() (handles ties)
SELECT *
FROM (
SELECT
region,
customer_name,
total_revenue,
DENSE_RANK() OVER (PARTITION BY region ORDER BY total_revenue DESC) AS rank
FROM customer_revenue
) ranked
WHERE rank <= 3;
-- Key Difference:
-- ROW_NUMBER: 1, 2, 3, 4 (no ties)
-- RANK: 1, 2, 2, 4 (ties share rank, skip)
-- DENSE_RANK: 1, 2, 2, 3 (ties share rank, no skip)
Question 2: Running Total and Moving Average
-- Question: Calculate running total and 7-day moving average
SELECT
order_date,
daily_revenue,
SUM(daily_revenue) OVER (
ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_total,
AVG(daily_revenue) OVER (
ORDER BY order_date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) AS moving_avg_7day,
COUNT(*) OVER (
ORDER BY order_date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) AS window_count
FROM daily_revenue
ORDER BY order_date;
-- Lag/Lead for period-over-period comparison
SELECT
order_date,
daily_revenue,
LAG(daily_revenue, 1) OVER (ORDER BY order_date) AS prev_day_revenue,
daily_revenue - LAG(daily_revenue, 1) OVER (ORDER BY order_date) AS day_over_day_change,
ROUND(
(daily_revenue - LAG(daily_revenue, 1) OVER (ORDER BY order_date)) * 100.0 /
NULLIF(LAG(daily_revenue, 1) OVER (ORDER BY order_date), 0),
2
) AS pct_change
FROM daily_revenue
ORDER BY order_date;
Question 3: Gaps and Islands
-- Question: Find consecutive days where a customer made purchases
WITH daily_purchases AS (
SELECT DISTINCT
customer_id,
DATE(purchase_timestamp) AS purchase_date
FROM purchases
),
numbered AS (
SELECT
customer_id,
purchase_date,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY purchase_date) AS row_num
FROM daily_purchases
),
islands AS (
SELECT
customer_id,
purchase_date,
DATEADD(day, -row_num, purchase_date) AS island_group
FROM numbered
)
SELECT
customer_id,
MIN(purchase_date) AS streak_start,
MAX(purchase_date) AS streak_end,
DATEDIFF(day, MIN(purchase_date), MAX(purchase_date)) + 1 AS streak_length
FROM islands
GROUP BY customer_id, island_group
HAVING DATEDIFF(day, MIN(purchase_date), MAX(purchase_date)) + 1 >= 3
ORDER BY streak_length DESC;
Question 4: Median and Percentiles
-- Question: Calculate median order value
-- Method 1: PERCENTILE_CONT (Snowflake, BigQuery)
SELECT
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY total_amount) AS median_amount,
PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY total_amount) AS p25_amount,
PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY total_amount) AS p75_amount,
PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY total_amount) AS p99_amount
FROM fact_orders;
-- Method 2: Manual median calculation
WITH ordered AS (
SELECT
total_amount,
ROW_NUMBER() OVER (ORDER BY total_amount) AS row_num,
COUNT(*) OVER () AS total_rows
FROM fact_orders
)
SELECT AVG(total_amount) AS median_amount
FROM ordered
WHERE row_num IN (FLOOR((total_rows + 1) / 2), CEIL((total_rows + 1) / 2));
System Design Questions
Question: Design a Real-Time Analytics Pipeline
Architecture Diagram
REQUIREMENTS CLARIFICATION:
- Sources: Web events (100M/day), DB CDC (10M/day), API (1M/day)
- Latency: Real-time dashboard (< 1 min), batch reports (daily)
- Users: 100 analysts, 10 data scientists
- Storage: 500 TB over 3 years
- Budget: $50K/month
<PipelineDiagram
title="Real-time ML Feature Pipeline"
stages={[
{ label: "Sources", sublabel: "CDC, Events", icon: "1", color: "#2563eb", bg: "#dbeafe" },
{ label: "Kafka", sublabel: "Buffer & Stream", icon: "2", color: "#7c3aed", bg: "#ede9fe" },
{ label: "Flink", sublabel: "Process & Window", icon: "3", color: "#d97706", bg: "#fef3c7" },
{ label: "Delta Lake", sublabel: "Storage", icon: "4", color: "#059669", bg: "#d1fae5" },
{ label: "Feature Store", sublabel: "Online / Transform", icon: "5", color: "#dc2626", bg: "#fee2e2" },
{ label: "Model Serving", sublabel: "API / BI Tools", icon: "6", color: "#7c3aed", bg: "#ede9fe" }
]}
width={750}
height={160}
/>
DEEP-DIVE COMPONENTS:
1. Ingestion: Kafka with schema registry, 3-day retention
2. Processing: Flink for windowed aggregations, exactly-once
3. Storage: Delta Lake on S3, partitioned by date
4. Serving: dbt for batch, Feature Store for real-time
5. Monitoring: Prometheus + Grafana for pipeline health
Question: Design a Data Warehouse for E-Commerce
Architecture Diagram
REQUIREMENTS:
- 10M orders/month, 100M events/day
- 50 analysts, 5 data scientists
- Sub-second dashboard queries
- 3-year historical retention
STAR SCHEMA DESIGN:
<div className="my-6 flex justify-center">
<svg viewBox="0 0 750 380" width="100%" style={{maxWidth: 750}} xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="de53grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stopColor="#3b82f6"/><stop offset="100%" stopColor="#2563eb"/></linearGradient>
<linearGradient id="de53grad2" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stopColor="#8b5cf6"/><stop offset="100%" stopColor="#7c3aed"/></linearGradient>
<linearGradient id="de53grad3" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stopColor="#06b6d4"/><stop offset="100%" stopColor="#0891b2"/></linearGradient>
<linearGradient id="de53grad4" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stopColor="#f59e0b"/><stop offset="100%" stopColor="#d97706"/></linearGradient>
<filter id="de53shadow"><feDropShadow dx="0" dy="2" stdDeviation="3" floodOpacity="0.15"/></filter>
</defs>
<rect x="10" y="10" width="730" height="360" rx="12" fill="#f8fafc" stroke="#e2e8f0" strokeWidth="1"/>
<text x="375" y="38" textAnchor="middle" fontSize="16" fontWeight="bold" fill="#1e293b">Star Schema Design</text>
<rect x="30" y="55" width="200" height="130" rx="8" fill="url(#de53grad1)" filter="url(#de53shadow)"/>
<text x="130" y="78" textAnchor="middle" fontSize="11" fontWeight="bold" fill="white">dim_customer</text>
<text x="130" y="96" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">customer_key, customer_id</text>
<text x="130" y="110" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">name, segment</text>
<text x="130" y="124" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">lifetime_value</text>
<text x="130" y="142" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.8">(SCD Type 2)</text>
<rect x="275" y="55" width="200" height="130" rx="8" fill="url(#de53grad2)" filter="url(#de53shadow)"/>
<text x="375" y="78" textAnchor="middle" fontSize="11" fontWeight="bold" fill="white">dim_product</text>
<text x="375" y="96" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">product_key, product_id</text>
<text x="375" y="110" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">name, category</text>
<text x="375" y="124" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">brand, unit_cost</text>
<rect x="520" y="55" width="200" height="130" rx="8" fill="url(#de53grad3)" filter="url(#de53shadow)"/>
<text x="620" y="78" textAnchor="middle" fontSize="11" fontWeight="bold" fill="white">dim_date</text>
<text x="620" y="96" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">date_key, full_date</text>
<text x="620" y="110" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">day_of_week, month</text>
<text x="620" y="124" textAnchor="middle" fontSize="8" fill="white" fillOpacity="0.9">quarter, year</text>
<line x1="130" y1="185" x2="130" y2="220" stroke="#94a3b8" strokeWidth="2"/>
<line x1="375" y1="185" x2="375" y2="220" stroke="#94a3b8" strokeWidth="2"/>
<line x1="620" y1="185" x2="620" y2="220" stroke="#94a3b8" strokeWidth="2"/>
<line x1="130" y1="220" x2="375" y2="220" stroke="#94a3b8" strokeWidth="2"/>
<line x1="375" y1="220" x2="620" y2="220" stroke="#94a3b8" strokeWidth="2"/>
<line x1="375" y1="220" x2="375" y2="250" stroke="#94a3b8" strokeWidth="2"/>
<polygon points="370,250 380,250 375,260" fill="#94a3b8"/>
<rect x="200" y="260" width="350" height="100" rx="8" fill="url(#de53grad4)" filter="url(#de53shadow)"/>
<text x="375" y="288" textAnchor="middle" fontSize="12" fontWeight="bold" fill="white">fact_orders</text>
<text x="375" y="306" textAnchor="middle" fontSize="9" fill="white" fillOpacity="0.9">order_key, customer_key, product_key, date_key</text>
<text x="375" y="322" textAnchor="middle" fontSize="9" fill="white" fillOpacity="0.9">quantity, net_amount, profit</text>
</svg>
</div>
PERFORMANCE OPTIMIZATION:
- Partition fact_orders by date_key
- Cluster by customer_key, product_key
- Materialized views for common aggregations
- Columnar storage (Parquet/Delta Lake)
Behavioral Questions (STAR Format)
Question: Tell me about a time you improved pipeline performance.
Architecture Diagram
SITUATION:
Our nightly ETL pipeline was taking 6 hours to complete, causing
SLA violations and delaying morning reports.
TASK:
As the lead data engineer, I was responsible for reducing pipeline
duration to under 2 hours while maintaining data quality.
ACTION:
1. Profiled the pipeline to identify bottlenecks
- Found: 80% of time spent in 3 large JOIN operations
2. Implemented incremental processing for fact tables
- Changed from full rebuild to MERGE-based incremental
3. Added partition pruning on date columns
- Reduced data scanned by 95%
4. Parallelized independent stages using Airflow TaskGroups
- Extract stage ran in parallel instead of sequential
5. Right-sized warehouse from Large to Medium
- Queue times were < 1 second, indicating over-provisioning
RESULT:
- Pipeline duration: 6 hours -> 45 minutes (87% reduction)
- Cost: $500/month -> $150/month (70% reduction)
- SLA compliance: 70% -> 100%
- No data quality incidents during the transition
Key Concepts Summary
| Topic | Common Questions | Key Concepts |
|---|---|---|
| SQL | Window functions, CTEs, joins | ROW_NUMBER, LAG, pivots |
| Data Modeling | Star vs snowflake, SCD | Grain, conformed dimensions |
| System Design | Pipeline architecture | Latency, throughput, fault tolerance |
| Big Data | Spark, Kafka, Flink | Distributed computing, partitioning |
| Cloud | Snowflake, BigQuery, Redshift | Compute-storage separation |
| Orchestration | Airflow, Dagster | DAGs, scheduling, retries |
| Testing | Data quality, pipeline testing | Assertions, monitoring |
| Behavioral | Leadership, conflict, impact | STAR framework |
Performance Metrics
| Interview Area | Prep Time | Success Rate | Priority |
|---|---|---|---|
| SQL Coding | 20-40 hours | 70-80% with practice | High |
| System Design | 30-50 hours | 60-70% with practice | High |
| Behavioral | 10-20 hours | 80-90% with practice | Medium |
| Data Modeling | 15-25 hours | 70-80% with practice | High |
| Cloud Platforms | 10-20 hours | 60-70% with practice | Medium |
| Coding (Python) | 20-40 hours | 60-70% with practice | Medium |
â ī¸
Common Mistake: Don't skip the fundamentals. Many production issues stem from misunderstanding basic concepts like data types, null handling, and idempotency. Always validate your assumptions.
Common Mistakes in Data Engineering Interviews
| Mistake | Why It Happens | How to Avoid |
|---|---|---|
| Jumping to solution | Eager to impress | Spend 2-3 minutes understanding the problem first |
| Ignoring scale | Focused on correctness | Always ask about data volume, latency, and user count |
| Forgetting trade-offs | Single-track thinking | Present multiple approaches and discuss pros/cons |
| Poor communication | Technical focus | Explain your thought process out loud |
| Not asking questions | Assuming understanding | Clarify requirements before designing |
| Skipping edge cases | Optimistic thinking | Discuss failure modes, null handling, and boundaries |
| Over-engineering | Impressing with complexity | Start simple, then optimize |
| Under-documenting | Code-focused | Explain why, not just what |
Technical Deep-Dive Topics
-- Window functions interview patterns
-- Pattern 1: Top-N per group
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY group_col ORDER BY value DESC) AS rn
FROM table
) WHERE rn <= N;
-- Pattern 2: Running totals
SELECT *, SUM(value) OVER (ORDER BY date_col ROWS UNBOUNDED PRECEDING) AS running_total
FROM table;
-- Pattern 3: Year-over-year comparison
SELECT *,
value - LAG(value, 12) OVER (ORDER BY month) AS yoy_change,
ROUND((value - LAG(value, 12) OVER (ORDER BY month)) * 100.0 /
NULLIF(LAG(value, 12) OVER (ORDER BY month), 0), 2) AS yoy_pct
FROM monthly_metrics;
-- Pattern 4: Percentile calculations
SELECT *,
PERCENT_RANK() OVER (ORDER BY value) AS percentile,
NTILE(4) OVER (ORDER BY value) AS quartile
FROM table;
10 Best Practices
- Practice SQL daily â solve 2-3 problems on LeetCode/HackerRank per day
- Study system design patterns â know batch vs streaming, push vs pull
- Master window functions â they appear in 80% of SQL interviews
- Prepare STAR stories â have 5-7 stories ready covering different competencies
- Know your resume â be able to explain every project in detail
- Ask clarifying questions â system design requires requirements first
- Draw diagrams â visualize architecture before explaining components
- Discuss trade-offs â show you understand pros/cons of different approaches
- Practice aloud â mock interviews reveal communication gaps
- Research the company â understand their tech stack and data challenges
See Also
- Data Warehouse Concepts â Star/snowflake schema for modeling questions
- Performance Optimization â Query tuning for optimization questions
- Real-Time Analytics â Streaming system design patterns
- Data Mesh Architecture â Architecture discussion topics
- Portfolio Projects â Building interview-ready portfolio
- Capstone: End-to-End â Comprehensive project for portfolio