Data Lake and Lakehouse
File formats and Parquet internals, partition layout on object storage, small files, Iceberg snapshots and metadata, row-level deletes, and concurrent commits.
10 questions
JuniorTheoryVery commonParquet, ORC, Avro or CSV/JSON — which goes to Kafka, to raw landing, to analytical tables?
Parquet, ORC, Avro or CSV/JSON — which goes to Kafka, to raw landing, to analytical tables?
Parquet and ORC are columnar: a query reads only the columns it names, each compressed apart, with min/max stats — analytical tables. Avro stores whole records with a schema — Kafka messages. CSV/JSON have no schema, parsed whole — raw landing.
Common mistakes
- ✗Believing the compression codec matters more than a row versus columnar layout for analytical reads
- ✗Writing one Parquet file per Kafka message instead of using a row format such as Avro
- ✗Keeping analytical tables in CSV or JSON, which loses types and column pruning
Follow-up questions
- →Which codec — snappy, zstd or gzip — would you choose for Parquet tables, and why?
- →How does Avro's schema let a producer add a field without breaking existing consumers?
JuniorDesignVery commonAn app sends about 500 GB of events a day to S3, stored as Parquet and queried with Spark and Trino. Almost every query filters on a date range of a few days; some also filter on country (about 200 values, a few of them hold most of the traffic), and the support team looks up single users by user_id (about 50 million users). A teammate proposes Hive-style directory partitioning with paths dt=…/country=…/user_id=…/, so that each of these filters prunes directories. Lay out the prefixes for this table, name a sensible size for its files, and explain what goes wrong with partitioning by user_id.
An app sends about 500 GB of events a day to S3, stored as Parquet and queried with Spark and Trino. Almost every query filters on a date range of a few days; some also filter on country (about 200 values, a few of them hold most of the traffic), and the support team looks up single users by user_id (about 50 million users). A teammate proposes Hive-style directory partitioning with paths dt=…/country=…/user_id=…/, so that each of these filters prunes directories. Lay out the prefixes for this table, name a sensible size for its files, and explain what goes wrong with partitioning by user_id.
Partition only by dt= (maybe hour=): nearly every query filters on it and its cardinality is bounded, so engines prune folders. user_id gives a folder per user, KB files, millions of partitions. Write files of hundreds of MB sorted by country, user_id.
Common mistakes
- ✗Partitioning by a high-cardinality column such as
user_idto speed up point lookups - ✗Adding partition levels until every filter prunes, multiplying folders and shrinking files
- ✗Expecting min/max statistics to replace directory pruning for the column almost every query filters on
Follow-up questions
- →When would adding
hour=underdt=be worth it for this table? - →How would a table format such as Iceberg change this layout with hidden partitioning?
JuniorTheoryVery commonWhat breaks with plain Parquet files in S3 that a table format such as Iceberg fixes?
What breaks with plain Parquet files in S3 that a table format such as Iceberg fixes?
Plain Parquet in S3 has no commit: S3 is atomic only per key and a "rename" is copy + delete, so readers see a job's files appear one by one. A table format lists the exact files in metadata and commits them by one atomic pointer swap.
Common mistakes
- ✗Blaming eventual consistency, which AWS S3 replaced with strong per-key consistency in December 2020
- ✗Assuming a directory rename on object storage is a single atomic operation
- ✗Thinking a table format is a new file format rather than metadata over Parquet files
Follow-up questions
- →Why does S3's strong read-after-write consistency not make a multi-file job atomic?
- →What do Hadoop's output committers for S3A do instead of renaming a job's directory?
MiddleDebuggingVery commonA stream commits to a table in table format Iceberg every minute, and queries slowed 10× — diagnose it
A stream commits to a table in table format Iceberg every minute, and queries slowed 10× — diagnose it
Each per-minute commit writes a file per task per partition — 57,600 files a day per partition, each a request and a footer read, plus manifests to plan over. Commit less often, cluster by partition, run rewrite_data_files, expire snapshots.
Common mistakes
- ✗Compacting without expiring snapshots, so the replaced small files stay on storage
- ✗Adding finer partitions, which multiplies the files each commit writes
- ✗Fixing only the Spark task layout and ignoring how often the stream commits
Follow-up questions
- →Why does
rewrite_data_filesfree no storage until the old snapshots are expired? - →How would you pick a trigger interval that still meets the 15-minute freshness target?
JuniorTheoryCommonAppending one file to a 1,000-file table in table format Iceberg — what does the commit write?
Appending one file to a 1,000-file table in table format Iceberg — what does the commit write?
Only new pieces: the data file, a manifest for it, a new manifest list (spec v1–v3) reusing the old manifests as is, and a new metadata.json with the snapshot. No data file is copied — snapshots reference files. Old snapshots stay until expired.
Common mistakes
- ✗Believing each snapshot is a physical copy of the table's data files
- ✗Expecting old snapshots to expire on their own, without a maintenance job such as expire snapshots
- ✗Thinking an append edits the current metadata file in place
Follow-up questions
- →What does an expire-snapshots job delete, and what does it take away from time travel?
- →Why does a stream of tiny appends pile up manifests, and how do you keep them in check?
MiddleTheoryCommonCopy-on-write vs merge-on-read for DELETE and MERGE in table format Iceberg — who pays, and when?
Copy-on-write vs merge-on-read for DELETE and MERGE in table format Iceberg — who pays, and when?
Copy-on-write rewrites each file with a changed row: slow writes, clean reads. Merge-on-read writes delete files that readers merge until compaction: cheap writes, slower reads. Iceberg sets it per operation, default copy-on-write; MoR needs format v2+.
Common mistakes
- ✗Expecting either mode to free storage before the old snapshots are expired
- ✗Switching to merge-on-read without scheduling compaction of the delete files
- ✗Expecting merge-on-read on a table still at format version 1
Follow-up questions
- →A CDC stream runs MERGE every five minutes — which mode would you pick, and what would you schedule?
- →How do format v3 deletion vectors differ from v2 position delete files?
MiddleTheoryCommonHow does a reader get from the catalog to a data file in table format Iceberg, and what is a commit?
How does a reader get from the catalog to a data file in table format Iceberg, and what is a commit?
The catalog points to the current metadata.json, whose snapshot names a manifest list (spec v1–v3) with partition bounds; manifests list data files with stats, so no S3 prefix is listed. A commit writes new files, then atomically swaps the pointer.
Common mistakes
- ✗Thinking the reader lists object-storage prefixes to find a table's files
- ✗Believing a commit edits the current metadata file in place under a lock
- ✗Treating the manifest list as permanent, though spec v4, still in development, is set to replace it with a root manifest
Follow-up questions
- →What exactly does the catalog check when two commits race for the same table?
- →How do the partition ranges in the manifest list let planning skip whole manifests?
MiddlePerformanceCommonHow does a reader of the columnar file format Parquet skip row groups, and when does it skip none?
How does a reader of the columnar file format Parquet skip row groups, and when does it skip none?
The footer, written last, holds each row group's column-chunk offsets and min/max stats. A reader reads it and skips row groups whose range can't match the filter. If data isn't sorted on that column, every range spans all values — sort on write.
Open full question →Common mistakes
- ✗Expecting min/max skipping on a column the data is neither sorted nor clustered by
- ✗Thinking the reader must decompress a row group before it can decide to skip it
- ✗Confusing row-group skipping inside a file with directory-level partition pruning
Follow-up questions
- →Why is a low-cardinality column like
device_typefar smaller on disk thansession_id? - →How do table formats such as Iceberg use the same statistics to skip whole files?
SeniorDesignOccasionalTwo Spark jobs write to the same table in table format Iceberg (format v2, a REST catalog). An hourly job appends that hour's events; a nightly job runs DELETE for users who asked to be erased and rewrites the affected files (copy-on-write). Both often start from the same snapshot S and commit minutes apart. Last week an hourly run's commit call timed out after its data files were written, the scheduler reran the whole job, and that hour's events now appear twice. Explain what happens when the second of two writers that started from S commits, which conflicts Iceberg resolves by itself and which end in failure, and how you would make a rerun after an unknown commit outcome safe.
Two Spark jobs write to the same table in table format Iceberg (format v2, a REST catalog). An hourly job appends that hour's events; a nightly job runs DELETE for users who asked to be erased and rewrites the affected files (copy-on-write). Both often start from the same snapshot S and commit minutes apart. Last week an hourly run's commit call timed out after its data files were written, the scheduler reran the whole job, and that hour's events now appear twice. Explain what happens when the second of two writers that started from S commits, which conflicts Iceberg resolves by itself and which end in failure, and how you would make a rerun after an unknown commit outcome safe.
The first commit moves the pointer off S, so the second's check-and-put fails; it refreshes, re-validates, retries (4 by default). Appends rebase; a serializable delete fails if another commit rewrote its files or added matching ones. After a timeout, look for its snapshot.
Open full question →Common mistakes
- ✗Rerunning an append after a commit timeout without checking whether its snapshot landed
- ✗Believing concurrent Iceberg writers silently overwrite each other's commits
- ✗Expecting every conflict to resolve on retry, including a delete whose files another commit rewrote
Follow-up questions
- →How would you record a batch id so a rerun can tell whether its snapshot already landed?
- →Why does a partition overwrite or a MERGE by event id make a rerun of the hour safe?
SeniorDebuggingOccasionalHourly partitions in table format Iceberg, yet queries on old hours still read whole days — why?
Hourly partitions in table format Iceberg, yet queries on old hours still read whole days — why?
Partition evolution is metadata-only: old files keep the daily spec, and Iceberg plans each spec apart, so an hour filter on old data prunes only to the day and reads whole unsorted daily files. Rewrite under the new spec only the history queries hit.
Open full question →Common mistakes
- ✗Expecting partition evolution to rewrite existing files into the new layout
- ✗Rewriting the whole history instead of only the ranges that queries actually read
- ✗Thinking queries must filter on a derived partition column rather than on
event_ts
Follow-up questions
- →How would you rewrite only the last 90 days of data under the hourly spec?
- →Why would sorting the old daily files by
event_tshelp without changing their partitioning?