Sub topic 2
The Footer: How Parquet Readers Find Everything
This chapter assumes basic tabular data, Python, schemas, and the difference between row-oriented and column-oriented storage.
The footer: how readers find everything
A Parquet reader usually starts at the end of the file. A Parquet file ends with:
- A four-byte footer length.
- A serialized
FileMetaDatafooter. - The magic bytes
PAR1.
The footer describes the schema, row groups, column chunks, compression codecs, encodings, byte offsets, and statistics. Because the reader can seek directly to the footer, it does not need to scan the whole file before deciding what to read.
Encodings: dictionary, run-length, and delta
Encoding changes values into a smaller representation before compression.
- Dictionary encoding stores repeated values once in a dictionary and writes short dictionary IDs. It works well for low-cardinality strings such as status names.
- Run-length encoding, or RLE, stores a value and the number of times it repeats. It is useful for repeated values and encoding definition or repetition levels.
- Delta encoding stores differences between adjacent values instead of full values. It can reduce timestamps or steadily increasing identifiers.
The writer can choose different encodings for different columns and pages. The footer records which encoding was used.
Compression codecs and their trade-offs
Compression then shrinks the encoded bytes. Codec choice affects file size, CPU use, and read speed.
| Codec | Typical trade-off |
|---|---|
| Snappy | Fast reads and writes, moderate compression |
| Zstandard | Strong compression with adjustable speed |
| Gzip | Small files, usually higher CPU cost |
| None | No codec cost, largest files |
For general analytics, Zstandard is often a useful default. Snappy can suit latency-sensitive pipelines. Test with representative data because actual results depend on value patterns.
> callout note > Encoding and compression are different steps: encoding changes representation, while compression removes repeated byte patterns.
Column statistics: min, max, and null count
Column-chunk metadata can include the minimum value, maximum value, and number of nulls. Readers use these statistics to avoid reading data that cannot match a filter. For example, a chunk with max = 500 cannot satisfy id >= 900.
Statistics are only safe when writers produce them correctly. Missing or inaccurate statistics reduce skipping or can threaten correctness, so readers must treat them conservatively.
Exercise
Why can a reader find column statistics without scanning every data value?
Show answer
The footer stores metadata and statistics, and the reader can locate the footer by seeking from the file end.