# Parquet

> Columns, row groups, compression and partitions: why Parquet is the file format for logs, and how the layout decides what a query has to read.

Source: https://jaredgore.com/guides/data-lakes/parquet/

Because JSON lines are a prank you play on your future self. Every row repeats its keys, there are no types, compression is mediocre, and every query reads every byte of every line. Parquet is the adult answer: columnar, typed, compressed per-column, self-describing. Same data, typically a tenth the size, and queries that read two columns out of twenty pay for two columns. JSON lines are fine for shipping logs around; Parquet is for keeping them.

## Columns, not rows

A query that reads two columns out of twenty reads exactly those two columns — the rest never leaves the disk. And because a column is all one type, compression actually works: a column of timestamps or repeated strings squeezes down to almost nothing. Row-wise formats store your users' email addresses interleaved with their session IDs interleaved with their user agents, and nothing nearby is similar, so nothing compresses. Columns give the codec something to work with.

## Row groups and statistics

Parquet splits each file into row groups, and every row group carries min/max statistics per column. When your query says `WHERE date = '2026-10-12'` or `WHERE status >= 500`, the engine checks the stats first and skips every row group whose range can't match — those pages are never opened. On a sorted column this is the difference between reading the file and reading one sliver of it. Which is also why sort order matters: an unsorted column gives you stats that match everything, which is stats that match nothing.

## Partitions

Catgirl University's lake is laid out the Hive way, one folder per table per day:

```
lake/
  auth/
    date=2026-10-12/part-0.parquet
    date=2026-10-13/part-0.parquet
    …
  storage/
    date=2026-10-12/part-0.parquet
    …
```

Partitioning is the same trick one level up: `date=2026-10-12/` is a folder, and a query filtered on `date` never opens the other days' files at all. Match the partition key to how you actually query — and how you query logs is almost always time, which is why this example uses it. The failure mode is over-partitioning: partition by `date/hour/user` and you get thousands of tiny files, and your "fast" lake spends all its time listing keys instead of reading data. Day-level partitions are right for nearly all security logs; go hourly only when the volume genuinely demands it. Fewer, bigger files — small files are their own special kind of pain.

## Look inside a file

Two commands and you can read any Parquet file's mind. `DESCRIBE SELECT * FROM 'lake/auth/date=2026-10-12/part-0.parquet'` tells you the columns and their types. `SELECT * FROM parquet_metadata('...')` tells you row groups, sizes, encodings and compression per column — which is how you confirm your writer didn't do something deranged. There's also `parquet_schema(...)` for the physical layout. Run these on one file before you query the whole lake; five minutes of inspection saves an hour of wondering why nothing matches.

## Check it

**A query reads two columns out of twenty. Why is that cheap in Parquet and not in JSON lines?**

Parquet stores each column on its own, so the other eighteen never leave the disk. JSON lines make you read every byte of every line.

**How do row-group statistics let an engine skip data, and why does sort order matter?**

Each row group records per-column min/max. The engine skips any group whose range can't match the filter. On an unsorted column every range matches everything, so nothing gets skipped.

**Why partition security logs by day and not by date/hour/user?**

Logs are queried by time, so day folders prune well. Over-partitioning makes thousands of tiny files, and the engine spends its time listing keys instead of reading data.

**Which commands show what's inside one Parquet file?**

DESCRIBE SELECT * FROM '<file>' for columns and types, parquet_metadata('<file>') for row groups, encodings and compression, and parquet_schema('<file>') for the physical layout.
