Topic 5 of 5 · 5 min read
Parquet files and lakehouse table formats
Goal: Choose a partition scheme and file size for a Parquet dataset and say when an Iceberg table is worth adding.
Parquet is a columnar file format; how you split it into folders and file sizes decides how much a query reads, and a table format such as Apache Iceberg or Delta Lake adds safe updates and history on top of those files. The files are cheap and portable. The layout is the part you design.
Check yourself · 1 of 3
Which column is the best partition key for a 3-year events dataset that is mostly queried by date range?
Why it matters
A Parquet dataset in object storage is queried by DuckDB, ClickHouse, Spark, BigQuery external tables and others. A good layout lets them skip most files. A bad one makes every query open thousands of tiny files or read everything.
How to do it
- Know the format. A Parquet file is split into row groups, and each column in a row group is stored as a chunk with min and max statistics. Engines use those statistics to skip row groups that cannot match a filter.
- Partition by what queries filter on. Folders such as
event_date=2026-11-30/let a date filter skip whole days. Pick a column with a modest number of values. Partitioning byuser_idcreates millions of folders. - Keep files a sensible size. Many tiny files are slow because of per-file open costs; very large files limit parallelism. A common target is a few hundred megabytes up to about a gigabyte per file, then tune for your engine.
- Sort within files by a column you filter on, so the statistics skip more.
- Add a table format when you need it. Plain Parquet folders have no transactions: a job that fails halfway leaves partial files that readers see. Iceberg and Delta Lake add a metadata layer that gives atomic commits, schema evolution (add or rename a column safely), time travel (query the table as of an earlier snapshot) and row-level deletes.
Before and after
A job writes one tiny file per hour per customer:
df.write.partitionBy("customer_id", "hour").parquet("s3://lake/events/")
That produces millions of small files. Partition by day and write larger files:
(df.repartition("event_date")
.sortWithinPartitions("customer_id")
.write.partitionBy("event_date")
.parquet("s3://lake/events/"))
Queries that filter on event_date now read only the matching folders.
What goes wrong
- Over-partitioning. High-cardinality keys create a small-file problem.
- Reading while writing. Without a table format, a reader can see half of a batch.
- Schema drift. Two files with the same column as different types break a query over the folder.
- Adding Iceberg too early. A single nightly job writing a folder read by one engine may need nothing more than careful naming.
Examples
Partition by day, not by user
s3://lake/events/event_date=2026-11-30/part-0001.parquet
s3://lake/events/event_date=2026-12-01/part-0001.parquet
A query for one week opens 7 folders. Partitioning by user_id instead would create a folder per user and a file per folder, and a week-long query would still touch all of them.
When Iceberg earns its place
Three jobs append to the same dataset while analysts query it, and last month a failed job left half a day of rows in the folder. Moving to an Iceberg table gives atomic commits, so readers see a batch completely or not at all, and lets you query last Tuesday's snapshot to explain a changed number.
Key points
- Parquet stores columns in row groups with min and max statistics that let engines skip data.
- Partition by a column queries filter on and that has few values, such as the event date.
- Avoid millions of tiny files; aim for files in the hundreds of megabytes and tune for your engine.
- Plain Parquet folders have no transactions, so readers can see a half-written batch.
- Iceberg and Delta Lake add atomic commits, schema evolution and time travel when several writers or readers need them.
Common mistakes
- Partitioning by a high-cardinality column such as a user id.
- Writing many tiny files and never compacting them.
- Letting readers query a folder that a job is still writing.
- Adopting a lakehouse table format for a single nightly job with one reader.
Check yourself · 2 of 3
A Parquet folder holds a million 100 KB files. What is the main problem?
Check yourself · 3 of 3
Three jobs write to one dataset while analysts query it, and a failed job once left half a batch visible. What would address this?
Practice items, not counted towards your mastery.
Start here
- DuckDB documentation (opens in a new tab)DocsFree
The engine's own reference for reading files, SQL syntax and functions.
- ClickHouse documentation (opens in a new tab)DocsFree
Official guides for column-oriented storage, ingestion and real-time analytics at scale.
- Apache Parquet documentation (opens in a new tab)DocsFree
The file format overview, with the specification of row groups and encodings.
More for this topic
- Apache Parquet file format (opens in a new tab)DocsFree
Defines row groups, column chunks and the statistics engines use to skip data.
- Apache Iceberg documentation (opens in a new tab)DocsFree
Explains snapshots, schema evolution, partition evolution and time travel for table metadata.