Data modelling¶
The vocabulary the commands share, and the rules that keep it from becoming a module everything depends on.
Commands agree on this page, not on a shared implementation. Each one declares the model itself — its own types, its own parsing — and this document is what makes those declarations interchangeable. A shared type couples every command to one module: a change reaches every user. A shared specification lets each command change on its own and still speak the same documents. That is the trade this page makes, and the reason it exists.
Three kinds of type¶
| kind | identity | parent | on the wire |
|---|---|---|---|
| Resource | a path-shaped name |
exactly one | one per line |
| Value type | none — a resource carries it | none | nested only |
| Document | none — it is a message | none | a method's body |
A resource is addressable: it has a name, one canonical parent, and
Get/List. A value type has no identity and is carried inside a resource —
FileStats in a TableFile, DeclaredColumn in a
Table. A document is neither: it is the body of a custom method's request or
response, such as a ReportRow or a ColumnRow.
Names¶
- A resource's first field is
name, the full resource name (AIP-122). - The collection segment identifies the type:
…/tables/{table}is aTable,…/blobs/{service}/{locator}is aBlob,…/columns/{column}is aColumn. A reader never needs a tag to know what a line is. - Names are relative (AIP-122) and are pqbench's own identifiers, not the backend's URL. The dialect maps a name to Unity's or Iceberg's REST endpoint, so no document carries a transport detail.
- An id segment is any string that is one URI path segment and decodes back to
what it names: a plain name, a URL-encoded path (
/as%2F), a dotted column path, or a number. Ids are not user-specified, so AIP-122 asks only that the format be documented here — its RFC-1034 character-set advice comes from the DNS spec and does not apply. - A resource's identity is
name; where the endpoint reports them,uid(UUID4) anddisplay_nameare output only. Noid, no self-link, no tuple (AIP-122/148). - A dotted FQN (
dbx_samples.nyctaxi.trips) is a lookup alias, input only. It is never a field and never appears in a document: the CLI translates it to the path form, and every returned document carries the canonical name. The CLI tells the two apart by the first segment — a known collection identifier is canonical, a dotted tuple is an alias. - A table no catalog named — one read by storage path — still gets a canonical
name: it takes the
localcatalog and schema, so every file under it has one too.
One canonical parent¶
A resource has at most one canonical parent, and a List must not require two
(AIP-124).
graph TD
Metastore --> Catalog
Catalog --> Schema
Schema --> Table
Table --> TableFile
Table --> Partition
TableFile --> Blob
Partition --> PartitionPrice
Partition --> Suggestion
Blob --> Column
Column --> Suggestion
| resource | canonical parent |
|---|---|
Catalog |
Metastore |
Schema |
Catalog |
Table |
Schema |
TableFile, Partition |
Table |
PartitionPrice |
Partition |
PartitionStats |
Catalog, Schema or Table (one pattern each, AIP-122) |
Column |
Blob |
Suggestion |
Column |
Blob is the exception: it is storage-rooted (blobs/{service}/{locator}), so
a bare object or a local path names a resource like any other, and it has no
parent. Bytemass is a value on Column, not a resource: one footer read
produces a column's mass with the column, so it has no name of its own.
Two consequences:
- A
TableFile's parent is the table, not its partition. Partition values ride on the file (itspartition_valuesmap). APartitionis a sibling under the table: the snapshot's files that share those values, folded into totals, with references to three of them (first_file,last_file,sample_file). - A storage class is a
Blobfact (storage_class), read from storage, not from the log, so it is not a livePartitionfield. A partition's price is its singleton child (…/partitions/{partition}/price, AIP-156), read withgetfrom the partition's record: the classes of the three referenced files' blobs, and the partition's bytes at each. The driver's store enriches aPartitionwith its processed time and the price's cost bounds; those fields are absent on a livelist partitionsrecord. - An analysis's parent is the column. A coarser scope is an aggregate, not a
second parent: a file-level read uses the
-wildcard id (AIP-159).
Fields¶
- Absence is
Option. There is no sentinel: a Rust enum has no_UNSPECIFIEDvalue, and an absent string isNone, not"". - Where a proto idiom is not the Rust idiom, Rust wins and the wire keeps the
proto's spelling through
serde. Proto requires a zero-value enum variant, a prefixed enum value, and anint64; the Rust type has a plain variant, an unsigned quantity, andserdespells the wire form back. - A quantity that cannot be negative is unsigned. A count is
_count, nevernum_(AIP-141). Units are spelled out —size_bytes, notsize. - An instant is
_time, integer milliseconds since the Unix epoch on the wire — the unit the logs already store, so a record passes it through, rather than AIP-142's RFC-3339 string. A span is_duration. A half-open window is[start_time, end_time)(AIP-145). - A range names its ends
first/last, inclusive, nevermin/max(AIP-145). A footer that spells themmin/maxkeeps that spelling, with anaipnaming: allow(aip-145/ranges)and the reason. - A field is a noun, not a verb (AIP-140), and a
boolcarries no verb prefix. - A nested message is a value type or a document, never a resource.
The wire¶
- One resource per NDJSON line, in the proto3 JSON mapping — except that field
names are spelled as here (
snake_case), not the mapping'slowerCamelCase, that a count or a size is a JSON number, not the mapping's string, and that an instant is integer milliseconds since the Unix epoch. An enum is its value name.
- No resource carries an envelope: no
kind, no per-documentversion. A stage reads exactly one resource type, identified by the name's collection segment, and a genuinely mixed stream is aoneof— never a tag on a resource. Theskilllisting is the one CLI document that keeps akindandversion. - The API version is the package's (
pqbench.v1), not a segment of a name. A name is self-describing by its collection segment, and no resource carries a version of its own. - AIP's field annotations are deliberately absent. The documents are native
Rust, so the type system carries what the annotations would describe — an
absent value is an
Option, an output-only field is not an input parameter — and there is no generator to read them. The AIP shape (names, patterns, field names) still applies. - Credentials are session state, never resource data. A reader resolves the
table's vended lease itself — a direct catalog call, with no in-process
cache — and holds it in memory; a
TableorTableFiledocument carries no keys. - A table references a blob through the
TableFileassociation, not as its parent (AIP-124).
The resource contract is v1.proto; the CLI-only documents are
described in Documents. This page is the rules that
keep the model coherent.
Where the model stops¶
This page is the vocabulary, not the API. Two rules keep it from becoming a coupling point:
- A command's signature takes the plain values it needs, not a document. A document passed whole makes every caller know every field, and a change to any field reaches every caller. Configuration, pagination, and dialect state belong to the implementation, never to the signature.
- The CLI owns the documents. It parses one, calls one command, and formats the result, so it is the place that stays flexible about inputs — composition is its job.
Adding a type¶
- Pick the kind. Addressable and listed? Resource. Carried inside one? Value type. A method's body? Document.
- A resource:
namefirst, one canonical parent, and only the standard identification fields (name,uid,display_name). - A value type or document: no
name, no parent, no identity. - Absence is
Option; no sentinel; Rust wins over the proto idiom. - A type with no producer yet is the design target. It stays in the model, and stays out of the wire until a command emits it.