Skip to content

Authentication

Local paths need no credentials. Remote objects and catalogs do. A table's vended lease overrides the process environment for that read and is not written back into it, nor onto a document. The Databricks authentication guide creates the service principal; this page is the reference for the variables and the credential flow.

Object storage (s3://)

Needs --features aws (or delta-s3 / iceberg-s3). The storage adapter builds an AmazonS3Builder from the default AWS provider chain, then applies the table's vended lease, when there is one.

Name Role
AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY Long-lived or vended keys
AWS_SESSION_TOKEN STS / Unity temp credentials
AWS_REGION Bucket region
AWS_PROFILE Process env only (shared config)
AWS_ENDPOINT / AWS_ENDPOINT_URL S3-compatible host (MinIO, rustfs)
AWS_ALLOW_HTTP true for http://
AWS_VIRTUAL_HOSTED_STYLE_REQUEST false for path-style
AWS_SKIP_SIGNATURE true for a public bucket

Process env (instance role, SSO, shared credentials):

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

Archive classes and tiers

An object in S3 GLACIER or DEEP_ARCHIVE, or in an Intelligent-Tiering ARCHIVE_ACCESS or DEEP_ARCHIVE_ACCESS tier, cannot be read until a restore has finished (GLACIER_IR and GCS ARCHIVE are online and always readable). get partition-price HEADs the files it samples without reading them, so it still prices an archived partition; its restore_required field records whether any sampled file needs a restore, and a completed restore clears it. A command that would read the body — bytemass, download — fails early with an error naming the storage class and the need to restore, instead of paying a storage request that can only fail. An absent or unknown class is read as usual; lint measures a local copy, so it never reads an archived object.

Catalog config (Unity / Databricks / Iceberg REST)

The walk's config resolves from three layers, least to most specific: ~/.pqbenchrc (an INI of named profiles, like ~/.databrickscfg), then the environment, then the command line. A profile names an endpoint, a bearer, and a dialect, so one workspace can carry [unity] and [iceberg] profiles; pick one with --profile (PQB_PROFILE), then override --endpoint / --token / --table-format for one run. Everything else is a per-invocation flag.

Variable Role
PQB_PROFILE the ~/.pqbenchrc profile to run under
PQB_ENDPOINT Databricks workspace URL, Unity OSS, or Iceberg REST base
PQB_TOKEN Bearer PAT (dapi-…) or OAuth token; catalog API only
PQB_CLIENT_ID / PQB_CLIENT_SECRET a service principal, when no static token is set
PQB_TABLE_FORMAT unity (the default) or iceberg; for iceberg the endpoint names the catalog base ({root}/v1 or {root}/v1/{prefix})
DATABRICKS_HOST / DATABRICKS_TOKEN a lower-priority fallback for the endpoint and bearer
DATABRICKS_CLIENT_ID / DATABRICKS_CLIENT_SECRET the same fallback for a service principal

The token is a Bearer on the catalog API only. Only AWS_* is copied onto listed tables. A PAT does not open s3://.

Service principal (OAuth M2M)

A service principal authenticates with a client id and secret instead of a long-lived token. Name them in the profile, or in the environment:

[DEFAULT]
endpoint      = https://dbc-abc123.cloud.databricks.com
client-id     = 0123-4567
client-secret = …
table_format  = unity

With no static token, pqbench mints the bearer in the process from POST {endpoint}/oidc/v1/token — HTTP Basic over client_id:client_secret, grant_type=client_credentials, scope=all-apis — on the first catalog request that needs one. The workspace holds the token and mints the next one five minutes before it expires, or at half its lifetime for a token shorter than ten minutes; a command therefore mints one token, not one per request.

A static token always wins, so a workspace with both configured uses the bearer an operator handed it. Neither the client secret nor a minted bearer is ever printed, and an error carries only the endpoint's error/error_description.

get metastore reads the same endpoint and reports its metastore record (name, uid, cloud_provider, region) as Metastore. list catalogs lists the catalogs at the endpoint, one Catalog line each (name, catalog_type); a system catalog (CATALOG_SYSTEM) and a catalog whose managed storage is Databricks default storage (CATALOG_DB_STORAGE), which no reader outside the workspace's compute can open, are not listed. get catalog reports one catalog's record (name, catalog_type, comment, owner) as a single Catalog line. list schemas lists the schemas in the catalog, one Schema line each (name, comment, uri); a schema the catalog keeps for itself (SCHEMA_SYSTEM, like information_schema) holds views over metadata and is not listed. Unity REST serves /schemas; with PQB_TABLE_FORMAT=iceberg (or "table_format": "iceberg" in the document) the command speaks Iceberg REST instead — the endpoint then names the catalog base ({root}/v1 or {root}/v1/{prefix}) and the command reads /namespaces under it. Unity is the default; no config probe runs.

The metadata levels pipe: PQB_ENDPOINT / PQB_TOKEN / PQB_TABLE_FORMAT carry the walk's context, and each level reads the parent's refs on standard input as they arrive — one Catalog line per catalog, then one Schema line per schema. Each ref's request starts as its record is read; --fan-out (64 on the listing levels and list files, one per core on get table) caps the requests in flight — it is a limit, not a batch: up to that many run at once on one thread, and rows are written as requests finish, not in ref order. Reading is demand-driven: a slow endpoint or a slow downstream pipe stops the reads, so the level above backpressures instead of buffering. A ref whose read fails — a timeout, a dropped connection, an endpoint answer such as a 429, or a storage fault — is dropped by the level: it names the ref and the cause on standard error, finishes the stream, and exits non-zero with the count, so one bad ref does not truncate a walk. The drop is only the read: a ref that does not name a resource, a record whose fields are wrong, or an output failure still fails the level. A level's requests are not paced: pacing is one process's job — point PQB_ENDPOINT at pqbench proxy and every level of the pipeline shares its cache and its one pacer, so the levels do not answer 429 in the first place; a 429 that does arrive holds the proxy's pacer for its Retry-After. A transient failure can still make a level fail, and the shell can retry the pipeline as it is.

list catalogs | list schemas lists every schema at the endpoint; list catalogs | get catalog enriches each catalog instead. get emits the same kind of resource as the list it reads from, so you can insert it into a walk or skip it; tee writes each level into the job tree.

$ PQB_ENDPOINT=https://example.cloud.databricks.com PQB_TOKEN=dapi-… \
>     pqb ls catalogs | pqb ls schemas
name                                   comment  uri
-------------------------------------  -------  ----------------------
catalogs/dbx_samples/schemas/bakehouse  …        s3://lakehouse/bakehouse
catalogs/dbx_samples/schemas/nyctaxi    …        s3://lakehouse/nyctaxi
catalogs/samples/schemas/accuweather    …        s3://lakehouse/weather

get schema reads one schema (name, display_name, comment, uri, properties) from Unity /schemas/{full_name} or Iceberg REST loadNamespace; it takes Schema records on standard input. list tables lists the tables in a schema, one Table line each — the document get table enriches. Unity's /tables pages carry the full name and storage location, so the ref is complete; Iceberg REST lists identifiers only, so the ref carries its name and no storage URI — get table derives the loadTable URL and reads the metadata inline. A view is not a table: it has no files, so list tables does not list it. Refs are addresses; the walk context (endpoint, token, storage options) comes from the configuration file, the environment, and the flags (PQB_*, AWS_*). The walk is a plain pipeline: every command streams refs and keeps --fan-out in flight. Each storage-reading command resolves the table's lease for itself — by calling the catalog's vending route, once per table for the command — and keeps it in memory. A view, a system table, or Databricks default storage has no lease the catalog will mint; that command fails for that ref, names the cause, drops it, and keeps the stream:

$ export PQB_ENDPOINT=… PQB_TOKEN=…
$ echo '"dbx_samples.nyctaxi"' |
>     pqb ls tables |
>     pqb get table |
>     pqb ls files |
>     pqb bytemass

The configuration file is the primary interface: ~/.pqbenchrc holds the profile, and PQB_CONFIG_FILE points at a different file. The committed examples/pqbenchrc can be used without a workspace:

$ PQB_CONFIG_FILE=examples/pqbenchrc pqb list catalogs

The endpoint and token resolve from the profile, then the environment, then the flags — the file supplies them without a command that prints exports. A workspace configured as a service principal mints its bearer in the process. A notebook kernel's dbutils context is not visible to a subprocess, so a notebook sets DATABRICKS_* from it first.

The first catalog listing is the preflight: it resolves the configuration, mints a service principal's bearer when needed, and asks the endpoint the first question the walk asks. A failed run names the endpoint, the credential, or the answer; neither the secret nor the bearer is printed.

Stateless clients, pacing, and the proxy

A pqbench command is a stateless HTTP client: it keeps no lease or bearer cache, so each storage-reading stage resolves the table's vended lease when it starts that table and sends a service-principal bearer with each request. Nothing is remembered between commands or between tables. A catalogs/local/… table is a path, not a catalog: it is read with the process's own AWS_* and never vends.

pqbench proxy is the one cache and the one pacer. It caches a 200 for an OAuth token, a vended credential, or a read-only catalog GET until just before the lifetime the upstream reported, keyed by method, path, the Authorization header, and the body. Two separate pqbench processes behind one proxy therefore ask the catalog once, and a request carrying another bearer — or none — is never answered from a first caller's entry. A credential-vending route also holds an ambient 400/403/404/501 — a catalog that does not vend — for a cached GET's TTL, so a walk does not re-ask for every file; a 401 or a 5xx is never cached.

The pacer lives in the proxy too. A command sends no more than its caller asks for, and a catalog that answers 429 is what a walk sees without the proxy. Pacing and cross-process sharing are the proxy's job because they are not per-call policy:

$ pqbench proxy --endpoint https://dbc-….cloud.databricks.com/api/2.1/unity-catalog
http://127.0.0.1:41021/api/2.1/unity-catalog
$ PQB_ENDPOINT=http://127.0.0.1:41021/api/2.1/unity-catalog pqbench list catalogs

--rps sets how many upstream requests a second the proxy makes; the default is 15 under the Unity dialect, the catalog's per-endpoint ceiling, and unpaced under Iceberg REST. 0 turns pacing off. The pacer is a strict interval — one request per 1 / rps seconds, no burst — shared by every process behind the proxy, and a 429 holds the slot for its Retry-After (one second when the answer names none, capped at a minute).

Its cache is the other half: a 200 for an OAuth token, a vended credential, or a read-only catalog GET is held until just before the lifetime the upstream reported, keyed by method, path, the Authorization header, and the body. Two separate pqbench processes behind one proxy therefore read the catalog once, and a request carrying another bearer — or none — is never answered from a first caller's entry. --ttl 0 keeps the token and credential caches and turns the GET cache off.

A service-principal command mints a bearer for each request, so the proxy's token cache is what turns a workspace's mint into one upstream call per token lifetime.

A ref the catalog will not vend for is dropped with the cause on standard error, and that stage exits non-zero; run the walk over a catalog that is externally readable, or filter the refs first.

The driver

pqbench-driver run --store DIR writes two standalone bash scripts into DIR and runs them: walk.sh lists every partition into partitions.ndjson.zst, and process-partition.sh prices and measures one partition. The runner is stateless and single-threaded: it has no socket, map, state machine, retry, or checkpoint. The version directories are the state, and PQB_DRIVER_STORE points pqbench list partitions, get partition, and summarize partitions at them.

  • The walk runs list catalogs | list schemas | list tables | get table | list partitions into the compressed listing. With --walk-tables FILE it runs list partitions over the Table records in FILE instead (for local tables). --walk-period-seconds skips the walk while {DIR}/_last_walk_time is fresh; without it every run walks.
  • Each partition runs process-partition.sh DIR PARTITION_JSON SAMPLE_JSON ETAG in its own process group: it prices the partition (get partition-price), then downloads the sample file and runs bytemass and lint on that copy, so every Suggestion it stores comes from lint. A version with no live file, or whose files need a restore, stops after its price. With --low-network no file is copied: bytemass reads the sample file's footer in place, and there is no column lint.
  • Idempotency. Before spawning anything, the runner checks the partition's directory: if _etag equals the walk's etag and _last_processed_time exists, it is an instant no-op. The script checks the same two files, so running it by hand is an instant no-op too.
  • Concurrency is --jobs N (default: one per CPU). Each step is bounded by step-timeout; a step that outlives it kills the script's whole process group, so no child outlives its step.
  • Append-only. After processing, a changed etag keeps its older version directory: the driver never deletes a result and never prunes a table the walk omits. pqbench prune is the one command that deletes versions.

A partition's results land in DIR/{catalog}/{schema}/{table}/{partition}/{etag}/: list-partitions.ndjson, price.ndjson, suggestions.ndjson, bytemass.ndjson, _etag, and _last_processed_time. A failed partition keeps its input in DIR/{etag}.failed/partition.ndjson (and DIR/{etag}.failed/sample.ndjson when there is a sample), and the driver prints the exact command that fixes it:

$ bash -x DIR/process-partition.sh \
    DIR/main/sales/orders/day%3D1/ETAG \
    DIR/main/sales/orders/day%3D1/ETAG.failed/partition.ndjson \
    DIR/main/sales/orders/day%3D1/ETAG.failed/sample.ndjson ETAG

Running that script by hand populates the version directory and removes its .failed directory, so the next pqbench-driver run treats the partition as a no-op. Both scripts read PQB_BIN (default pqbench on PATH) and can be run on their own.

pqbench list partitions [PARENT] --store DIR prints one Partition per partition, from its newest finished version: all of them, or those under a catalog, schema, table or partition name. Each record is enriched with its last_processed_time and, when the version was priced, its lowest_cost_per_month and highest_cost_per_month. Without --store it reads Table records on standard input, as a live walk. pqbench summarize partitions totals the records per catalog, schema and table as PartitionStats, including processed_partition_count.

pqbench get partition NAME --store DIR reads the partition's newest stored results: its PartitionPrice, its lint Suggestions, its column masses from bytemass, then its listing, one record per line.

Two settings of the driver's own — step-timeout and retained-version-count — live only in the same run-control file; see Configuration.

$ 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 prune --store /var/lib/pqbench --dry-run
$ bash /var/lib/pqbench/walk.sh

Databricks-governed tables

A governed table has two access modes, and pqbench is the second one:

  • Engine-mediated. Notebooks, SQL, and BI drivers ask Databricks compute to read the table; the platform reaches storage with its own identity and no cloud credentials reach the caller. Use spark.sql / the SQL warehouse for this; pqbench does not.
  • Credential-mediated. An external reader calls the catalog's vending route and reads storage itself under a short-lived, downscoped lease — the get table → list files → bytemass walk, with the lease held by the reader's process rather than carried on the documents.

Whether the second mode exists is the storage's property, not the caller's:

Table storage External read under a vended lease
External location (customer S3), external table yes
External location, managed table yes
Databricks default storage, managed table no — the catalog reports TABLE_DB_STORAGE; the vending route refuses, and the objects deny externally issued sessions
Managed volume files via FUSE in compute or the Files API; not a table read

The vending route is the answer: it mints a lease for an external location and refuses a view, a system table, or Databricks default storage. There is no separate eligibility stage; the storage-reading command that asked for the lease reports the refusal and drops that ref.

Two environment notes:

  • The vended response carries the keys, a session token, and the storage URL, but no region: set AWS_REGION (or the client's equivalent) for the read.
  • Inside serverless compute, Unity refuses to mint storage credentials to notebook code (UC_SERVERLESS_UNTRUSTED_DOMAIN_STORAGE_TOKEN_MINTING); the reader falls back to the ambient AWS_* and the compute's own engines. Classic compute reaches storage through its instance profile.

References