Skip to content

One binary for Parquet optimization

Measure how a Parquet file spends bytes.

Get started CLI reference GitHub

Apache-2.0 OR MIT · CI · native binaries for Linux and macOS, x86_64 and arm64 · Python wheel

After Umberto Boccioni, Dynamism of a Cyclist, 1913: the mark is the study itself, the ground is drawn from its motifs.

bytemass — bytes per column
$ pqbench bytemass examples/quickstart.parquet --format table
column  type   codec         encodings                 bytes  values
------  -----  ------------  ------------------------  -----  ------
id      INT64  UNCOMPRESSED  PLAIN,RLE,RLE_DICTIONARY    102       8
year    INT32  UNCOMPRESSED  PLAIN,RLE,RLE_DICTIONARY     68       8
files: 1
rows: 8
columns: 2

Overview

Measure how well each codec compresses a Parquet file and how many on-disk bytes each column costs. Byte masses come from the footer and the table metadata, not the data pages, so they are fast on files of any size.

Commands compose on pipes — each writes a typed pqbench.v1 document the next reads — so the whole job is one pipeline. The walk goes from a catalog's tables to the bytes each column costs.

Quick start

Install the released pqbench binary (Linux and macOS, x86_64 and arm64):

curl -LsSf https://github.com/pqbench/pqbench/releases/latest/download/pqbench-cli-installer.sh | sh

The installer verifies the download against the release checksums and puts pqbench in ~/.cargo/bin, with pqb as a symlink to it. To pin a version, build from source, or read about the release process, see Distribution.

The walk, end to end

pqbench's whole job is one walk: descend a catalog, narrow to a table's files, and measure the bytes each column costs. Every stage streams JSON to the next, so the walk is one bash pipeline.

# ~/.pqbenchrc
[DEFAULT]
endpoint     = https://<workspace>.cloud.databricks.com
token        = dapi-…
table_format = unity
$ set -euo pipefail
$ pqb ls catalogs \
    | pqb ls schemas \
    | pqb ls tables \
    | pqb get table \
    | pqb ls files \
    | pqb bytemass \
    | pqb fmt

Read it left to right:

  • ~/.pqbenchrc names the endpoint, credential, and dialect; --profile picks a profile and a flag overrides one run. See Configuration.
  • list catalogs, list schemas, list tables, and get table descend the catalog. A live endpoint rate-limits its REST calls, so point PQB_ENDPOINT at pqbench proxy: it caches the catalog's answers and paces every stage at 15/s, the catalog's per-endpoint ceiling.
  • With no static token, a Databricks service principal in the profile authenticates with its client-id and client-secret (or PQB_CLIENT_ID and PQB_CLIENT_SECRET): the process mints the OAuth M2M bearer on its first catalog request and mints the next one five minutes before it expires. Neither the secret nor the bearer is printed. See Authentication.
  • A storage-reading stage resolves the table's vended lease itself, once per table rather than once per file, and caches it for the command. The leases are held in memory and never appear in a document.
  • get table enriches each ref with its format and snapshot; the Delta log is read with without_files(), so the read is O(1) in files. list files then resolves each snapshot and writes its active files, one TableFile per line.
  • bytemass reads each file's footer and prints the on-disk bytes per column, the table in bytemass. In a pipe it streams Blob and Column NDJSON instead; pqb fmt renders the columns as a table and pqb format --html draws one file's stream as a treemap. For a whole warehouse, pqbench-driver writes one result per partition and summarize partitions rolls them up across catalogs, schemas, and tables.

A ref the catalog will not vend a lease for — a view, a system table, a table on Databricks default storage — is dropped with the cause on standard error, and that stage exits non-zero; set -e then stops the pipeline. Walk a catalog that is externally readable, or filter the refs to one first (scripts/dbx-walk.sh shows the jq filter). The lease itself is never written to a document.

The same walk runs offline against the local Delta and Iceberg stand, make lakehouse. Getting started takes one Parquet file to a treemap, and the CLI reference documents every command.

Showcases

Showcases runs the commands as jobs on real public data — triage which columns own the file, choose a codec, verify a layout change, and read SQuAD and a TPC-DS table from the wild. On a 2.1 MB Reddit comments sample, three of seven columns are 99.7% of the bytes:

$ pqb table-file crates/pqbench-cli/tests/fixtures/small_reddit_none.parquet | pqb bytemass | pqb fmt
column            type        codec         encoding   bytes  dict bytes  bytes/row  values
----------------  ----------  ------------  --------  ------  ----------  ---------  ------
text              BYTE_ARRAY  UNCOMPRESSED  dict      743566      738658     247.86    3000
label             BYTE_ARRAY  UNCOMPRESSED  dict        2469         527       0.82    3000
dataType          BYTE_ARRAY  UNCOMPRESSED  dict         360          33       0.12    3000
communityName     BYTE_ARRAY  UNCOMPRESSED  dict        2468         527       0.82    3000
datetime          BYTE_ARRAY  UNCOMPRESSED  dict          87          28       0.03    3000
username_encoded  BYTE_ARRAY  UNCOMPRESSED  dict      446197      441331     148.73    3000
url_encoded       BYTE_ARRAY  UNCOMPRESSED  dict      907117      901963     302.37    3000

lint and compression explain it. The Showcases page walks them end to end.

Commands

The core measurements. The walk's get and list come first; the CLI reference covers every command, and Documents maps the records they exchange.

lz

lzbench-style compression benchmark over raw file bytes. The default sweeps every wired codec (zstd, lz4, gzip, snappy); -c codec@level (repeatable) picks one config:

$ pqb lz data/samples/squad.parquet --samples 1 --warmup-iterations 0 | pqb fmt
codec   level  compress MB/s  decompress MB/s  ratio
------  -----  -------------  ---------------  -----
gzip        1            ±44             ±226   0.85
zstd        1           ±915            ±1391   0.85
lz4         1          ±2176            ±5180   0.98
snappy      1          ±1608            ±1981   0.99

Speeds vary run to run; the stream is NDJSON.

compression

The same sweep over a parquet file's encoded pages. The input must be NONE-compressed; --per-column adds a report per column.

$ pqb compression crates/pqbench-cli/tests/fixtures/small_reddit_none.parquet --samples 1 --warmup-iterations 0 | pqb fmt
codec   level  compress MB/s  decompress MB/s  ratio
------  -----  -------------  ---------------  -----
zstd        1           ±458            ±1722   0.56
gzip        1            ±68             ±270   0.58
lz4         1           ±897            ±8476   0.81
snappy      1           ±912            ±2101   0.81

The stream is NDJSON.

bytemass

Per-column byte masses — the on-disk bytes each column takes, with its value count, its chunks summed over the file's row groups.

$ pqb table-file data/samples/delta_byte_array.parquet | pqb bytemass | pqb fmt
column                 type        codec         encoding          bytes  dict bytes  bytes/row  values
---------------------  ----------  ------------  ----------------  -----  ----------  ---------  ------
c_customer_id          BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   8248           0       8.25    1000
c_salutation           BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   3362           0       3.36    1000
c_first_name           BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   6595           0       6.59    1000
c_last_name            BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   6955           0       6.96    1000
c_preferred_cust_flag  BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   1220           0       1.22    1000
c_birth_country        BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   9599           0       9.60    1000
c_login                BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY     42           0       0.04    1000
c_email_address        BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY  27763           0      27.76    1000
c_last_review_date     BYTE_ARRAY  UNCOMPRESSED  DELTA_BYTE_ARRAY   3511           0       3.51    1000
  • Reads only the footer, so it works on any file, compressed or not.
  • Reads TableFile records on stdin: table-file PATH names one path or URI, and list files names a table's files.
  • s3:// needs the aws feature; a pipe streams one Blob per file and one Column per column.

Filtering which files to measure is a shell job on the list files stream — see Visual demos.

lint

The storage a file's values do not need. lint measures every rewrite the file's footer and one representative row group make plausible, and writes one suggestion per winning change with the bytes it saves:

$ pqb lint crates/pqbench-cli/tests/fixtures/small_reddit_none.parquet | pqb fmt
COLUMN            RULE     SAVINGS  REMEDY                                                                               MESSAGE
----------------  -----  ---------  -----------------------------------------------------------------------------------  ------------------------------------------------------------------
text              codec  431.7 KiB  compression={'text': 'zstd'}, compression_level={'text': 3}                          uncompressed at 247.86 B/value; 59%-65% smaller at zstd levels 1-3
url_encoded       codec  295.9 KiB  compression={'url_encoded': 'zstd'}, compression_level={'url_encoded': 3}            uncompressed at 302.37 B/value; 33% smaller at zstd levels 1-3
username_encoded  codec  169.5 KiB  compression={'username_encoded': 'zstd'}, compression_level={'username_encoded': 3}  uncompressed at 148.73 B/value; 39% smaller at zstd levels 1-3

Each rule detects a column, then measures a controlled rewrite — the sample written under the candidate setting at the file's own codec and level — in a single pass. The first rule that detects a column and verifies a saving claims it, so a column's bytes are never priced twice. --target selects the engine that will rewrite the file — spark, delta, iceberg, pyarrow, parquet-rs, or duckdb — and without it the footer's created_by writer decides. A per-column knob stays one suggestion per column; a file- or table-wide knob (Delta's delta.parquet.compression.codec, for one) rolls the file's verified columns into a single suggestion with no column.

Fifteen rules read one column's chunk; the first that detects a column wins, so a column's bytes are never priced twice:

Rule What it finds Remedy
uuid-text canonical UUID text, 36 bytes for 16 of data write it as BINARY(16)
base64-text Base64 text of binary payloads, four characters per three bytes decode it to a binary column
int96-timestamp the deprecated INT96 timestamp write an INT64 microsecond timestamp
text-timestamp every value is ISO-8601 timestamp text write a microsecond INT64 timestamp
numeric-text canonical integer or decimal text, a character per digit write it as INT64 or DOUBLE
int64-narrow INT64 values whose whole range fits INT32 write the column as INT32
decimal-narrow a wide DECIMAL whose precision fits an integer write it as an INT32 or INT64 decimal
codec a chunk a stronger or lighter codec stores in fewer bytes write the column with the winning codec family
page-size many tiny data pages from a low page-size limit write it with the standard 1 MiB page size
delta-integer dense or monotone integers without DELTA_BINARY_PACKED write the column Delta binary packed (page v2)
dictionary-unique a dictionary page on nearly unique values write the column without a dictionary
dictionary-missing repeated values written without a dictionary write the column with one
delta-text-encoding nearly-unique text without a dictionary write Delta byte/length arrays (page v2)
dictionary-fallback a dictionary that fell back to PLAIN data pages raise the dictionary page size limit, or turn the dictionary off
stats-truncated footer min_value/max_value past 64 bytes truncate statistics at 64 bytes

dictionary-unique, dictionary-missing, and dictionary-fallback cover every physical type a dictionary can pay on — byte arrays, fixed-length byte arrays, INT32, INT64, FLOAT, and DOUBLE — and dictionary-fallback prices three arms at the file's own codec, keeping the smaller of a raised limit and no dictionary. page-size is measured as a controlled pair: the source's own effective page size against the standard 1 MiB, at the file's codec and encoding. base64-text reads only values that are canonical Base64 of binary bytes: a UUID, a hex digest, and a word all use Base64 characters without being one, and a decoded payload that is mostly printable is a text column, not a binary one. stats-truncated needs no re-encode: a footer's bounds are the writer's own bytes, so the bytes past the truncation length are exact.

uuid-text, base64-text, text-timestamp, numeric-text, int64-narrow, decimal-narrow, delta-integer, delta-text-encoding, the dictionary rules, and page-size decode and re-encode a leaf's values, so they measure scalar leaves only. codec and stats-truncated read page headers, page bytes, and footer facts, so they measure any leaf, nested list<struct> columns included.

A suggestion's remedy is the setting the selected target takes — parquet-mr keys, pyarrow and parquet-rs write options, a Delta table property — and savings_bytes is the measured difference against the source's own bytes. lint rewrites the sample under each candidate setting in one pass, so every suggestion it emits is verified; nothing is only potential.

list files

List a table's active files — the files its snapshot holds now.

$ cat docker/e2e-lakehouse/table.ndjson | pqb ls files | pqb fmt
path                                                                 size_bytes
-------------------------------------------------------------------  ----------
part-00000-5eef9a52-f717-4d78-8e62-d7a2a05c707b-c000.snappy.parquet         796
  • Reads each table's Delta / Iceberg log and checkpoint, never the data files.
  • --last 1m|1h|1d|1w keeps the files the log dates in the window ending now.
  • --partition 2026-10-28 keeps one UTC day.
  • One line per file, written as the walk produces it: the run holds one log batch plus one file per table in flight (--fan-out).
  • Delta needs --features delta, Iceberg iceberg; add -s3 to either for s3://.
  • Reads Table refs on standard input (a get table stream).

The files are the input to bytemass:

$ cat docker/e2e-lakehouse/table.ndjson | pqb ls files | pqb bytemass | pqb fmt
column  type        codec   encoding  bytes  dict bytes  bytes/row  values
------  ----------  ------  --------  -----  ----------  ---------  ------
id      INT64       SNAPPY  dict         66          37      22.00       3
label   BYTE_ARRAY  SNAPPY  dict         72          43      24.00       3

The lease rides on every file, so a short-lived lease travels to bytemass. A producer names a file with table-file; AWS_* in the environment (or a vended lease on the file record) supplies storage access:

$ pqb table-file s3://bucket/table/part-0.parquet | AWS_PROFILE=analytics pqb bytemass | pqb fmt

format --html

Draw one file's bytemass (list columns) stream as a static HTML column treemap — no server, no build step.

$ pqb table-file data/samples/delta_byte_array.parquet | pqb bytemass | pqb format --html > /tmp/report.html
$ cat docker/e2e-lakehouse/table.ndjson | pqb ls files | pqb bytemass | pqb format --html > /tmp/report.html

The page lands at /tmp/report.html. Open it in a browser.

The driver

pqbench-driver writes two plain bash scripts into a store and runs them: walk.sh lists every partition into partitions.ndjson.zst, and process-partition.sh prices and measures one partition. The runner only bounds concurrency (--jobs) and preserves failures; there is no socket, no state machine, and no retry, and the runner is one thread. A partition is done when its _etag matches the walk and it has _last_processed_time, so rerunning is an instant no-op. A changed etag is a new version directory; the run is append-only, and pqbench prune deletes the versions beyond the retained count:

$ pqbench-driver run --store /var/lib/pqbench --walk-period-seconds 86400
$ export PQB_DRIVER_STORE=/var/lib/pqbench
$ pqbench list partitions catalogs/main/schemas/sales
$ pqbench get partition catalogs/main/schemas/sales/tables/orders/partitions/day%3D1
$ pqbench list partitions | pqbench summarize partitions
$ pqbench prune --store /var/lib/pqbench --dry-run

A failed partition keeps its input in DIR.failed/ and prints the exact command that fixes it, for example bash -x /var/lib/pqbench/process-partition.sh DIR DIR.failed/partition.ndjson DIR.failed/sample.ndjson ETAG. Running that by hand populates DIR and removes DIR.failed/, so the next driver run treats it as a no-op. The store keeps each partition under {catalog}/{schema}/{table}/{partition}/{etag}/. Two operator settings — step-timeout and retained-version-count — change rarely enough to live only in ~/.pqbenchrc; see Configuration. Each script's commands resolve their own leases and pace their own catalog requests; local tables need neither.

Documentation

Start with Getting started. The documentation index maps every page by kind. pqb --help is the command guide; pqb <command> --help is local to that command.

  • Getting started — install, first measurement, the metadata walk
  • Showcases — real jobs on real data: triage the bytes, pick a codec, verify a layout change
  • Distribution — install the binary, targets, and how releases are cut
  • CLI reference — every command, generated from the clap tree
  • Documents — the records the commands exchange
  • Authentication — object storage, catalog config, and governed tables
  • Visual demos — Parquet, Delta, Iceberg, catalog walk, and Unix file selection
  • Delta tables — log load, list files | bytemass, limitations
  • Iceberg tables — metadata load, list files | bytemass, limitations
  • Format and HTML — pqb format, tables and the static HTML treemap
  • Python — install the binary wheel; run the CLI, read the files
  • Unity Catalog and Iceberg REST E2E — catalogs naming tables for pqb ls files, over rustfs S3

Python

python/ ships the same binary as a Python wheel: pip install pqbench puts pqbench on your PATH. There is no Python extension and no importable module — the CLI is the interface, and the files it writes are the data. For streaming pipelines, see the Python orchestration guide.

$ pip install pqbench
$ pqbench list files < docker/e2e-lakehouse/table.ndjson | zstd -3 > /tmp/files.jsonl.zst
import polars as pl

files = pl.scan_ndjson("/tmp/files.jsonl.zst")

Contributing

PRs welcome. The gate is make check (fmt-check + check-docs + clippy -D warnings + isolation + lfs-check + test). The Python wheel is make check-python. The runnable commands on this page are generated into tests by docscheck (make sync-docs); see CONTRIBUTING.md for the loop, style, and naming rules.

License

Dual-licensed under MIT or Apache-2.0.