Rapid-fire theory

Part of the free LogicWiz Data Engineering course, Module 18: Interview rounds. The SQL and Python run in the app, on real Postgres and real Python in the browser.

It is the rapid-fire round: fifteen minutes and no editor. The interviewer reads from a list: "How much memory does one Spark task get? What makes a Delta commit atomic on S3? What does acks=all wait for? Why is my Postgres table three times bigger than its rows?" Nobody wants a lecture. They want what the engine does, one number, and what it means for you, in under thirty seconds. And they notice at once when the words are memorised.

You'll learn to

  • Answer the most-asked "how" questions in two or three sentences
  • Give the mechanism, a real default and the consequence every time
  • Turn the rules into small functions you can test

Learn

How the round runs

Ten to fifteen short questions in about fifteen minutes. For a senior role most of them are how questions, and a strong answer has three parts:

  1. The mechanism: what the engine does, and with which data structure.
  2. A number: the default, or the formula.
  3. The consequence: what breaks, and what you would change.

If you do not know, reason out loud from the mechanism. Never bluff a default.

Here is one answer built that way. The question: "How does AQE handle skew?"

One answer in three parts: "How does AQE handle skew?"

Three steps of one interview answer: the mechanism (AQE reads real partition sizes at a shuffle boundary), a number (over 5 times the median and over 256 MB, split to about 64 MB) and the consequence (it fixes skew in joins, not in aggregations).

Read it top to bottom, out loud, and time yourself. That is the whole answer, in under thirty seconds.

Spark internals

TermThe short answer
Unified memory0.6 x (heap - 300 MB) is shared by execution and caching (spark.memory.fraction); half of it (storageFraction 0.5) is cache that execution cannot evict.
Per-task memoryWith N tasks running, each can get between 1/(2N) and 1/N of the execution pool before it spills.
OverheadOff-heap room in the container: max(384 MB, 0.10 x executor memory) by default. Exceed it and the cluster manager kills the container.
Shuffle writeSort-based: each map task writes one data file and one index file, ordered by reduce partition, spilling sorted runs when memory runs out.
CatalystParse, analyse against the catalog, optimise with rules (push filters, prune columns), plan physically (pick the join), generate code per stage.
Join choiceBroadcast hash when a buildable side is under 10 MB (autoBroadcastJoinThreshold), else sort-merge. A full outer join never broadcast-hashes.
AQERe-plans at each shuffle from real sizes: coalesces to 64 MB, splits skew (5x median and 256 MB), switches to broadcast. On by default since 3.2.

How to use these four tables: cover the right column, say your answer out loud, then compare. Mechanism, number, consequence.

Files and table formats

TermThe short answer
ParquetRow groups (128 MB by default in parquet-java), column chunks, pages of about 1 MB; the footer holds the schema and min/max per chunk, so filters skip row groups.
Delta commitWrite the Parquet files, then create deltalog/<version.json only if it does not exist yet; the loser re-checks for conflicts and tries the next version.
Delta checkpointA Parquet summary of the log every 10 commits in open-source Delta; readers start from lastcheckpoint and replay only the JSON after it.
Delta conflictsConcurrentAppendException: files were added where you read. ConcurrentDeleteReadException: a file you read was removed. MetadataChangedException: the schema changed.
Iceberg commitWrite a new metadata file, then the catalog swaps the table's pointer to it atomically if nobody else did; otherwise re-read and retry (4 retries by default).
VACUUM (Delta)Deletes data files removed from the table more than 7 days ago (delta.deletedFileRetentionDuration); time travel to versions that need them then fails.

Kafka and Structured Streaming

TermThe short answer
ReplicationA leader and followers; the ISR is the replicas caught up within replica.lag.time.max.ms (30 s). Consumers read only up to the high watermark.
acksacks=all (the default since 3.0) waits for every ISR member; min.insync.replicas (default 1) is how small the ISR may get before writes are refused.
Idempotent producerA producer id plus a sequence number per partition lets the broker drop retried duplicates. On by default since 3.0.
TransactionsWrites to many partitions plus consumer offsets commit or abort together; readcommitted consumers stop at the last stable offset and skip aborted data.
Partition assignmentWithin a group each partition has one consumer. The range assignor gives each consumer, sorted by id, a block of partitions; extra consumers sit idle.
Streaming checkpointoffsets/ is written before a batch runs, commits/ after it finishes, state/ holds versioned state; a restart replays an offset with no commit.
State and watermarkWatermark = latest event time seen minus the delay. Windows ending before it are emitted and their state dropped; without a watermark state grows forever.

Databases and warehouses

TermThe short answer
MVCCEvery row version carries xmin (the creating transaction) and xmax (the deleting one); a snapshot decides which versions each query sees.
VACUUM (Postgres)Removes dead versions no snapshot can still see. A transaction left open, or a slot's old xmin, holds it back and tables bloat.
Logical decoding and CDCThe WAL is decoded into row changes through a replication slot, which keeps WAL until the reader confirms it: a stopped reader fills the disk.
Snowflake storageMicro-partitions of 50 to 500 MB uncompressed, with per-column ranges in metadata, so a filter prunes whole micro-partitions.
Snowflake computeWarehouses burn credits per hour by size (X-Small 1, doubling each size), billed per second with a 60-second minimum per resume. Results are reused for 24 hours.
BigQueryOn-demand bills bytes scanned: $6.25 per TiB, at least 10 MB per table. Capacity pricing buys slots instead.

The same idea keeps coming back: a log of changes, a pointer to the current version, and a rule for who sees what. Delta, Iceberg, Kafka, the streaming checkpoint and MVCC are all variations of it.

One row's journey, and the question asked at each hop

A graph following one order from a Postgres row version through Kafka and Structured Streaming running on Spark executors into a Delta table made of Parquet files and finally a warehouse query, each node labelled with the internals question interviewers ask there.

Follow one order from left to right. Use it as a map: when a question lands, place it on a hop first, then give that hop's mechanism and number.

Practise each answer out loud: mechanism, number, consequence, under thirty seconds. Then tie it to something you ran: "our nightly MERGE and a backfill hit ConcurrentAppendException, so we put the date range in the merge condition". One real incident makes ten memorised definitions believable.

The trap: answers that sound right and are wrong. "acks=all means every replica has it" (every replica in the ISR, which can shrink to the leader). "VACUUM keeps time travel working" (only within the retention). "A task gets 1/N of the memory" (it is guaranteed only 1/(2N)). "Delta commits with a lock" (it is optimistic: put-if-absent, then conflict checks). "Exactly once means delivered once" (it means counted once in the result). "More executors fix one slow task" (not when the task is skewed).

Remember: mechanism, number, consequence. Thirty seconds, then stop talking.

Next is the internals round: the same mechanisms, but now you write the rule as code.

In one line

Answer each question in three parts, the mechanism, one real number and the consequence, in under thirty seconds, and never bluff a default.

Interview corner

How does Spark share an executor's memory between caching and execution?

After 300 MB reserved, 60% of the heap is one unified region (spark.memory.fraction); on a 16 GB heap that is about 9,650 MB. Execution and storage borrow from each other, but execution can evict cached blocks only down to storageFraction, half the region, and cached blocks can never evict execution memory. Within execution, each of N running tasks is guaranteed 1/(2N) and may take up to 1/N, so with 4 cores a task gets 1,206 to 2,413 MB before it spills. Outside the heap, the container also needs overhead, 10% or at least 384 MB, and that is the part a container kill is about.

How do Delta Lake and Iceberg make a commit atomic on object storage, which has no transactions?

Both write the data files first and make them visible with one atomic step. Delta creates the next numbered JSON file in _delta_log with put-if-absent; if another writer took that number, it reads the winner's commit, checks for conflicts (files added in partitions it read, files it read that were removed) and tries the next number. Iceberg writes a new metadata file and asks the catalog to swap the table's pointer, which only succeeds if the pointer has not moved, retrying up to 4 times by default. Readers only ever see the version a pointer or the log says is current.

How do Kafka's idempotent producer and transactions give exactly-once processing?

The idempotent producer, on by default since Kafka 3.0, sends a producer id and a per-partition sequence number, so the broker drops a retried duplicate. Transactions go further: a consume-transform-produce app writes its output messages and its consumer offsets in one transaction, which commits or aborts as a whole. Downstream consumers set isolation.level=read_committed, read only up to the last stable offset and skip aborted data. Outside Kafka, for example into Delta, you still need an idempotent sink, because the transaction does not reach the external system.

What is MVCC, and how does it connect to CDC?

In Postgres every UPDATE writes a new row version with the transaction id in xmin and stamps the old one's xmax; each query's snapshot decides which versions it sees, so readers never block writers. The cost is dead versions, which VACUUM removes once no snapshot can see them; a long open transaction or a slot's old xmin stops that and tables bloat. Every change is also written to the WAL, and logical decoding through a replication slot turns the WAL into row-level change events in commit order: that is what Debezium reads, and why a stopped connector makes the slot keep WAL until the disk fills.