Skip to content
Bronze 7 min read · All formats 2 practice problems ↓

Parquet and columnar storage

Parquet is the file format behind almost every data lake and lakehouse table. Its trick is storing data by column with small summaries inside, so engines can skip most of a file without reading it. This lesson opens a Parquet file and shows how that skipping works.

Step 3 · Data lake & lakehouse · Bronze · Lake foundations, lesson 3 of 3

In plain words first

A spreadsheet printed row by row makes you read every line to add up one column. Printed column by column, you only read the column you need. Now add a sticky note on each page saying "amounts on this page range from 10 to 90": looking for amounts over 1,000, you can skip the whole page without reading it.

Parquet is the column-by-column printout, and the sticky notes are its statistics.

Inside a Parquet file

File layout

part-00000.parquet
├── Row group 0  (e.g. 128 MB of rows)
│   ├── Column chunk: order_id   → pages
│   ├── Column chunk: country    → pages
│   └── Column chunk: amount     → pages
├── Row group 1
│   └── ...
└── Footer
    ├── Schema
    └── Per row group, per column: min, max, null count, offsets
    "PAR1"
  • Row group: a horizontal slice of rows. Writers commonly target around 128 MB.
  • Column chunk: the values of one column within a row group, stored together.
  • Page: the unit of encoding and compression inside a chunk, around 1 MB.
  • Footer: at the end of the file, the schema and statistics. Readers read it first.

Why columnar reads less

Analytic queries touch a few columns of wide tables. In a row format (CSV, JSON, Avro), reading one column means reading every byte of every row. In Parquet, the reader seeks straight to the column chunks it needs.

QueryRow format readsParquet reads
SELECT SUM(amount) on a 100-column tableAll 100 columns1 column (about 1% of the data, before compression)

Values of one column are also similar to each other, so they compress far better than mixed rows: dictionary encoding replaces repeated strings with small integers, run-length encoding collapses runs of the same value, and a general codec (Snappy by default in Spark, or ZSTD) compresses the result.

Skipping data with statistics

For a filter like amount > 10000, the reader checks each row group's max for amount in the footer. If the max is 9,500, the whole row group is skipped without reading it. This is predicate pushdownpredicate pushdown: Applying a filter while reading files, so data that cannot match is skipped instead of read. Learn more → at the file level.

Query · the filter

SELECT * FROM orders WHERE order_date = '2025-03-14' on a file with four row groups.

Footer · the stats

Row group 0: dates Jan 1 to Feb 10. Row group 1: Feb 10 to Mar 9. Row group 2: Mar 9 to Apr 2. Row group 3: Apr 2 to May 1.

Skip · the result

Only row group 2 can contain March 14, so only it is read: 25% of the file. If the data had not been sorted by date, every row group would span all dates and nothing could be skipped.

That last point is the most important practical lesson: statistics help only when data is clustered by the filtered column. Sorting, Z-orderingZ-order: Sorting data by several columns at once, so queries filtering on any of them can skip more files. Learn more → and liquid clustering exist to make min/max ranges narrow.

Sizes that matter

  • Files of 128 MB to 1 GB keep per-file overhead low (see The small file problem).
  • Row groups around 128 MB balance skipping granularity against overhead; tiny row groups waste footer space and compress poorly.
  • Nested data (structs, arrays) is stored column by column too, using repetition and definition levels, so reading one nested field does not read the rest.
Note: Parquet is immutable: there is no way to update a row in place. Every update or delete means writing a new file. This is exactly why table formatstable format: A metadata layer (Delta Lake, Iceberg, Hudi) that turns a folder of data files into a table with commits, versions and a schema. Learn more → exist.

Try it yourself

Each example says what it shows, then the output from a real run and what to notice in it, so you can follow without running anything. To try one yourself, paste it into a local Spark session with Delta Lake, with spark already created: each builds its own data.

Goal: Write Parquet laid out for the queries that will read it: one folder per date, rows sorted by customer, zstd compression.

Production patternPySpark · Tune a Parquet write for the queries that will read it
import glob

events = spark.range(0, 500_000).selectExpr(
    "id", "id % 2000 AS customer_id", "rand(7) * 100 AS amount",
    "date_add(DATE'2025-03-01', CAST(id % 7 AS INT)) AS event_date")

(events
    .repartition("event_date")                  # one task per date folder
    .sortWithinPartitions("customer_id")        # narrow min/max per row group
    .write.mode("overwrite")
    .option("compression", "zstd")
    .option("parquet.block.size", 128 * 1024 * 1024)    # row group size (the default)
    .partitionBy("event_date")
    .parquet("lab/parquet/events"))

one_customer = spark.read.parquet("lab/parquet/events").where("customer_id = 42")
print(one_customer.count(), "rows for customer 42")
for folder in sorted(glob.glob("lab/parquet/events/event_date=*")):
    files = glob.glob(folder + "/*.parquet")
    print(folder, len(files), "file,", files[0].rsplit(".", 2)[-2], "compressed")

Output from a real run

250 rows for customer 42
lab/parquet/events/event_date=2025-03-01 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-02 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-03 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-04 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-05 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-06 1 file, zstd compressed
lab/parquet/events/event_date=2025-03-07 1 file, zstd compressed

What to notice:

  • Seven date folders, one file each: repartition("event_date") gave one tasktask: The work for one partition in one stage, run on one CPU core. Learn more → per date.
  • Every file is zstd-compressed, as set by compression.
  • Sorting by customer_id inside each file is what lets a reader skip most of the file for one customer: the next lab shows it.

Goal: See why sorting matters: Parquet can skip row groups only when similar values sit together.

ExplorePySpark · Row-group skipping only works when the data is clustered
import glob
import pyarrow.parquet as pq

# 1 MB row groups, to get several per file
ROW_GROUP = 1024 * 1024


def groups_that_may_match(path, value):
    meta = pq.ParquetFile(glob.glob(f"{path}/*.parquet")[0]).metadata
    stats = [meta.row_group(i).column(1).statistics for i in range(meta.num_row_groups)]
    return sum(1 for s in stats if s.min <= value <= s.max), len(stats)


df = spark.range(0, 1_000_000).selectExpr("id", "id % 100 AS customer")
for name, data in [("by_customer", df.orderBy("customer")), ("by_id", df)]:
    (data.coalesce(1).write.mode("overwrite")
         .option("parquet.block.size", ROW_GROUP).parquet(f"lab/parquet/{name}"))
    may, total = groups_that_may_match(f"lab/parquet/{name}", 42)
    print(f"sorted {name}: {may} of {total} row groups may contain customer 42")

Output from a real run

sorted by_customer: 1 of 6 row groups may contain customer 42
sorted by_id: 5 of 5 row groups may contain customer 42

What to notice:

  • Sorted by customer: only 1 of 6 row groups can contain customer 42, so the other 5 are skipped.
  • Sorted by id: all 5 row groups might contain customer 42, because each holds customers 0 to 99. Nothing can be skipped.
  • Same data, same filter; only the order differs.

Common mistakes

  • Expecting statistics to help on unsorted data — If every row group spans all values, nothing can be skipped.
  • Writing thousands of tiny Parquet files — Footer reads and opens dominate.
  • Selecting * from wide tables — Throws away the columnar advantage.

Key takeaways

  • Parquet stores columns separately inside row groups, with statistics in the footer.
  • Engines read only the needed columns and skip row groups using min/max values.
  • Skipping works only when data is clustered by the filtered column.
  • Parquet files are immutable; updates mean new files.

Interview prep

THE QUESTION

"Why is Parquet faster than CSV for analytics?"

Columnar layout reads only needed columns; similar values compress well with dictionary and run-length encoding; footer statistics allow skipping row groups (predicate pushdown); and types are stored, so there is no parsing. Mention that skipping depends on clustering and that files are immutable.

Avoid: "Parquet is compressed" only. Say columnar layout, encodings, and the statistics that let readers skip row groups.

Follow-ups · answer out loud, then open

Follow-up"What is a row group, and how big should it be?"
A horizontal slice of the file (128 MB by default in Spark's writer) holding one column chunk per column, each with min/max statistics. Large enough for efficient sequential reads, small enough to give several splits per file and useful skipping.
Scenario"Queries filter on customer_id, but Parquet skips almost no row groups. Why?"
Row group min/max statistics only help when values are clustered. If every row group contains customer ids from the whole range, min and max cover everything. Sort or cluster the data by customer_id when writing (sortWithinPartitions, Z-order, liquid clustering).
Trap"Parquet files can be updated in place to change one row."
Parquet files are immutable. Changing a row means writing a new file; table formats track which files are current, using copy-on-write, delete files or deletion vectors.

Check yourself

3 questions

Where are a Parquet file's column statistics stored?

Show the answer

In the footer. The footer holds the schema and per-row-group statistics.

A filter is on customer_id but the data is sorted by date. What does row-group skipping achieve for that filter?

Show the answer

Probably very little, since each row group spans many customer_ids. Min/max ranges are wide for unsorted columns, so few row groups can be ruled out.

Why does columnar data compress well?

Show the answer

Values of the same column are similar, suiting dictionary and run-length encoding. Homogeneous columns compress far better than mixed rows.

Practise this

Interview problems on data lake, graded on hidden tests

Keep going

Up next · new module: Table formats · 6 min read
Open table formats
Delta Lake, Iceberg and Hudi: a metadata layer that turns a folder of Parquet files into a table.

Related lessons

Previous: Data lake storage: formats and layout

Primary sources: Apache Parquet documentation · Spark: Parquet files