Documents¶
The commands exchange typed JSON documents. A resource is one line, identified
by the collection segment of its name; a value type is nested inside the
resource that carries it; a document is a command's own output when it has no
addressable name. Data modelling is the
contract; v1.proto is the field-by-field resource
schema.
Resource records¶
| Record | Name | Produced by | Consumed by |
|---|---|---|---|
Metastore |
metastores/{metastore} |
get metastore |
humans / scripts |
Catalog |
catalogs/{catalog} |
list catalogs, get catalog |
get catalog, list schemas |
Schema |
catalogs/{catalog}/schemas/{schema} |
list schemas, get schema |
get schema, list tables |
Table |
catalogs/{catalog}/schemas/{schema}/tables/{table} |
list tables, get table |
get table, list files, list partitions |
TableFile |
…/tables/{table}/files/{file} |
list files, sample files, table-file |
sample files, bytemass, download |
Partition |
…/tables/{table}/partitions/{partition} |
list partitions (live or from the driver's store) |
get partition, get partition-price, summarize partitions |
PartitionPrice |
…/partitions/{partition}/price |
get partition-price |
humans / scripts |
PartitionStats |
{catalog, schema or table}/partitionStats |
summarize partitions |
humans / scripts |
Blob |
blobs/{service}/{locator} |
bytemass |
humans / scripts |
Column |
blobs/{service}/{locator}/columns/{column} |
bytemass |
format, format --html, humans / scripts |
Suggestion |
blobs/{service}/{locator}/columns/{column}/suggestions/{rule}, or {blob}/suggestions/{rule} for a file-wide knob |
lint |
humans / scripts |
The Bytemass value is nested in Column.mass; it
has no resource name of its own. Besides the column chunk's own bytes, it
carries the file's metadata accounting, which costs no extra read:
footer_bytes (the serialized footer plus its eight-byte trailer, from the
footer's own length) and unaccounted_bytes (the object's size less the sum of
its chunks: footer, page indexes, bloom filters, key-value metadata). Both are
file facts, so every column of a file carries the same pair, and a fold over
sampled files weights them like the other additive quantities.
A resource's name is its identity. The collection segment (catalogs,
schemas, tables, files, partitions, blobs, columns) names the type, so no resource
carries a kind or a version of its own — the API version is the package's
(pqbench.v1). A dotted FQN such as dbx_samples.nyctaxi.trips is an
input-only lookup alias; the CLI translates it to the canonical path name.
Command documents¶
Some commands emit a document that is not a resource: it has no addressable
name, or it is a listing that is meant to be read rather than piped.
| Document | Produced by | Shape |
|---|---|---|
ReportRow |
lz, compression |
name, codec, level, compress_estimate, decompress_estimate, compressed_bytes, uncompressed_bytes, ratio |
ColumnRow |
compression --per-column |
ReportRow fields plus column |
Skill |
skill (no arguments) |
kind: "pqbench.skill", version, name, description, documents |
Skill is the one document that keeps an explicit kind and version: it is
a listing, not a resource stream.
Sampling¶
sample files keeps a rate of the TableFile stream, by size, so a table's
footers can be measured without reading every file:
$ cat docker/e2e-lakehouse/table.ndjson | pqb list files | pqb sample files --rate 1 2>/dev/null | 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
--rate 1 keeps every file; the stage's coverage line is on standard error, so
the pipe above hides it to show the table. A file is kept with probability
rate × size / 256 MiB, capped at one, drawn from a hash of its name: the
same record always makes the same decision. A 256 MiB file is kept at
get partition-price sets restore_required when a sampled file is in an S3
archive class or tier without a completed restore; a HEAD-only price still
works, and a command that would read the body fails early instead.
--rate (the default keeps about one in a hundred), a 1 GiB file four times
as often. The decision
needs only the record's name and size, which the log already carries, so the
stage streams and never holds the table.
Each kept TableFile records the probability it was kept with as
sample_rate; bytemass copies it, with the file's size_bytes and
storage_class, onto every Column (the Blob carries it too), so a column
prices its own storage. bytemass and lint also record the footer's
created_by as writer, so a suggestion's remedy matches what the file's
writer can actually change; savings_bytes is the difference the controlled
rewrite measured. Scale
only the additive quantities by its inverse — size_bytes, compressed_bytes,
uncompressed_bytes, footer_bytes, unaccounted_bytes, dictionary_bytes,
unencoded_bytes, value_count,
null_count, row_group_count, a Suggestion's savings_bytes — and
recompute the ratios (bytes_per_value,
bytes_per_row, compression_ratio, null_fraction, dictionary_fraction)
from the weighted sums; distinct_count is not additive. A sum over the kept
records alone is the sample, not the table — the coverage line on standard
error says how many files and bytes it holds. A record that already carries a
sample_rate composes with the smaller of the two probabilities, since both
threshold the same hash. A record with no positive size is an error, not a
silent drop.
Filtering by path or partition is still a shell job on the list files stream
(jq, sort, head, xargs) — see Visual demos.
bytemass reads its files in flight (--fan-out, 128 by default), so the
per-file footer round trips overlap instead of adding up.