Data engineering interview questions: Set 3 (Mid-level)
Set 3: 30 mid-level data engineering interview questions with explanations, on SQL, data modelling, Spark, Kafka, lakehouse, pipelines, data quality, cloud…
||joins two strings in SQL. What does this return? SQL · EasySELECT 'data' || NULL;- data
- dataNULL
- NULL
- An error
A customer’s city is stored as Pune and changes to Delhi. With an SCD Type 1 change, what happens to the customer’s row? Data modelling · Easy
- A new row is added for Delhi and the Pune row is kept
- Pune is overwritten with Delhi, and no history is kept
- A previous_city column is added
- The row is deleted
What is a partition of a Spark DataFrame? Spark · Easy
- A folder on disk
- A machine in the cluster
- A column of the DataFrame
- A chunk of rows that one task processes
What is the main difference between stream processing and batch processing? Streaming & Kafka · Easy
- Streaming processes events continuously, within seconds of arrival; batch processes a bounded chunk, such as yesterday’s data, at once
- Streaming is always cheaper than batch
- Batch cannot handle more than a million rows
- Streaming does not need any storage
What do you write inside a dbt model file such as
models/orders.sql? Pipelines & orchestration · Easy- A CREATE TABLE statement
- A SELECT statement; dbt wraps it in the CREATE or MERGE it needs
- Python code only
- Only YAML configuration
A medallion lakehouse has three layers: bronze, silver and gold. What belongs in silver? System design · Easy
- Raw data exactly as received
- Business aggregates for dashboards
- Cleaned, deduplicated and standardised data, the trusted base for everything else
- Archived data no one reads
sortedtakes akeyfunction that decides what to sort by. What does this print? Python · Easyrows = [("bo", 30), ("ana", 25), ("cy", 30)] print(sorted(rows, key=lambda r: r[1]))- [('ana', 25), ('bo', 30), ('cy', 30)]
- [('ana', 25), ('cy', 30), ('bo', 30)]
- [('bo', 30), ('ana', 25), ('cy', 30)]
- [('ana', 25), ('bo', 30)]
Values are 10, 20, 30 and 40, one per day. The frame covers the current row and up to 2 rows before it. What is in
ma, in day order? SQL · MediumSELECT d, AVG(v) OVER (ORDER BY d ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS ma FROM t;- 10, 15, 20, 30
- 20, 30, 40, 40
- 10, 20, 30, 40
- 25, 25, 25, 25
You add
ROW_NUMBER() OVER (...) AS rnto a SELECT and then writeWHERE rn = 1in the same query. It fails. Why? SQL · Medium- ROW_NUMBER needs an ORDER BY
- rn is a reserved word
- You need a GROUP BY first
- WHERE runs before window functions are computed, so rn does not exist yet
The
statuscolumn has four rows: paid, refunded, paid and NULL. Someone wants to count paid orders. What does this return? SQL · MediumSELECT COUNT(CASE WHEN status = 'paid' THEN 1 ELSE 0 END) FROM orders;- 2
- 4
- 3
- 1
The order number (
ORD-1042) is useful for grouping and searching, but it has no other attributes worth a table. Where does it go, and what is it called? Data modelling · Medium- A column in the fact table with no dimension table: a degenerate dimension
- A dimension table with one column: a junk dimension
- A separate fact table: a factless fact
- A bridge table between orders and products
A fact table has two dates:
order_dateandship_date. Both need day, month and holiday attributes. How do you model this? Data modelling · Medium- Keep two separate date tables and keep them in sync
- Use one date dimension, joined twice, once in each role (with aliases or two views)
- Store the dates as text
- Use a bridge table
Every data file records the minimum and maximum of each column. You Z-order (or cluster) a lakehouse table on
customer_id. What does that improve? Storage & formats · Medium- The compression codec used
- It deletes old files
- Rows with similar customer_ids end up in the same files, so a filter on customer_id can skip most files using their min and max
- It sorts the partitions by date
Time travel lets you read an older version of a Delta table. The table is VACUUMed every day with 7 days of retention, which deletes data files older than 7 days that the current version no longer uses. Can you read the version from 30 days ago? Storage & formats · Medium
- Yes, the transaction log keeps every version forever
- Only with a MERGE
- Only on Iceberg tables
- No: the log still lists that version, but VACUUM has deleted its files
Two tables hold the same 10 GB. One is 100,000 files of 100 KB, the other is 100 files of 100 MB. Why is the first much slower to read? Spark · Medium
- Small files compress worse
- Each file has a fixed cost (listing, opening, reading its footer, scheduling), and with 100,000 files that cost is bigger than the reading
- Small files are encrypted
- Spark reads only the first 1,000 files
Spark must join two large tables on
customer_id. Neither fits in memory. Which join strategy does it use? Spark · Medium- Broadcast hash join
- Cartesian product
- Sort-merge join: both sides shuffled by key, sorted, then merged
- Nested loop join
A Kafka producer sends a message, and the broker leading that partition replies "received". Then that broker dies. Which setting makes sure the message survives? Streaming & Kafka · Medium
- acks=0
- acks=1
- linger.ms=0
- acks=all, with min.insync.replicas=2 on the topic
XCom passes values between Airflow tasks. A task pushes a 2 GB DataFrame to XCom for the next task. Why is that a bad idea? Pipelines & orchestration · Medium
- XComs are stored in Airflow’s metadata database, which is meant for small values; write the data to storage and pass its path
- XCom only works with small integers
- XCom deletes the data after one read
- Tasks are not allowed to share data
A dbt incremental model contains
{% if is_incremental() %} WHERE updated_at > (SELECT MAX(updated_at) FROM {{ this }}) {% endif %}. What does it do? Pipelines & orchestration · Medium- Runs only on the very first build
- Turns the model into a view
- Deletes old rows from the table
- On later runs, limits the query to rows newer than what the table already has
Daily revenue suddenly drops 40%, but every not_null, unique and accepted_values test passes. Which kind of check would have flagged it? Data quality · Medium
- More not_null tests
- A check that compares the metric with its recent history and alerts on unusual changes
- A unique test on another column
- A schema check
A Spark cluster in the us-east-1 region reads 50 TB a day from a bucket in eu-west-1. What is wrong? Cloud · Medium
- Nothing, regions do not matter
- Buckets cannot be read from another region
- Data leaving a region is charged per GB and is slower: run the compute in the bucket’s region
- It needs a VPN
A new analyst finds three tables called revenue, revenue_v2 and revenue_final, and nobody can say which one finance uses. What prevents this? Governance & security · Medium
- Delete two of the tables
- A data catalog where each table has an owner, a description and a certified or deprecated status
- Give the tables longer names
- Put all tables in one schema
Why write
with open(path) as f:instead off = open(path)followed byf.close()at the end? Python · Medium- It reads the file faster
- The file is closed even when an exception happens inside the block
- It opens the file in binary mode
- It locks the file so no one else can open it
A user logged in on days 1, 2, 3, 5 and 6. The query subtracts each row’s position (1, 2, 3, 4, 5) from its day. What is in
grp, in day order? SQL · HardSELECT day, day - ROW_NUMBER() OVER (ORDER BY day) AS grp FROM logins;- 0, 0, 0, 1, 1
- 1, 1, 1, 2, 2
- 0, 1, 2, 3, 4
- 1, 2, 3, 5, 6
An Iceberg table is partitioned by
days(event_ts), which means Iceberg derives the day from the timestamp itself. A query filtersWHERE event_ts >= '2026-11-01', with no separate date column. Are partitions skipped? Storage & formats · Hard- No, you must also filter on a date column
- Only after running OPTIMIZE
- Yes: Iceberg turns the timestamp filter into a day filter and skips older days
- Only in Spark 4
Someone adds
.cache()to a 2 TB DataFrame that is used only once. The job gets slower. Why? Spark · Hard- Storing 2 TB spills to disk and pushes other data out of memory, and with one use nothing pays it back
- cache() makes every job slower
- cache() turns off the optimiser
- cache() forces a broadcast
Two Spark streams, orders and payments, are joined on
order_id, with no watermark and no time limit. What happens over the following weeks? Streaming & Kafka · Hard- Spark refuses to start the query
- The join becomes a batch job
- Memory use keeps growing, because Spark must keep every order and payment in case a match arrives later
- Duplicate rows appear
What is the write-audit-publish pattern? Data quality · Hard
- A write-ahead log inside the database
- A Kafka setting
- An audit log of who wrote what
- Write new data where readers cannot see it, run the checks, and make it visible in one step only if they pass
During a shuffle, executors write intermediate files to their own disks for the next stage to read. An autoscaling cluster removes idle executors mid-job, and later stages redo work because those files vanished. What prevents this? Cloud · Hard
- Turn off task retries
- An external shuffle service or shuffle tracking, so shuffle files survive or their executors are kept
- A second driver
- Cache every DataFrame
Lambda architecture runs a batch pipeline and a streaming pipeline side by side and merges their results. What is Kappa architecture? System design · Hard
- Separate batch and streaming layers whose results are merged
- A batch-only design
- A Kafka broker setting
- A single streaming pipeline; to reprocess history you replay the stored log through the same code
Other sets
- Set 1 · Junior: 30 questions (15 easy, 12 medium, 3 hard), free
- Set 2 · Junior: 30 questions (14 easy, 13 medium, 3 hard), paid
- Set 4 · Mid-level: 30 questions (6 easy, 17 medium, 7 hard), paid
- Set 5 · Senior: 30 questions (0 easy, 9 medium, 21 hard), free
- Set 6 · Senior: 30 questions (0 easy, 9 medium, 21 hard), paid