Reference#
Use these pages to look up the Python API, commands, caller fields, result metadata and common failures. For complete examples, see Quickstart, Python and Rust.
Python API reference lists every public Python class and method with its parameters, return values and errors.
Commands#
peql [--root DIR] COMMAND
--root selects the workspace and defaults to the current directory. Use peql COMMAND --help for all options on a command.
Command |
Purpose |
|---|---|
|
Register a YAML/JSON contract against a CSV or Parquet sample. |
|
Register a YAML/JSON contract as parcel compiled it ( |
|
Write CSV/Parquet under a contract; replaces existing data by default. |
|
Print the validation verdict as JSON. |
|
Execute one read-only SQL query. |
|
Show the columns exposed to a caller. |
|
Show registered contracts, publication and data status for the operator. |
|
Share contract visibility; use |
|
Set a named privacy budget’s limit per caller. |
|
Register a parcel WebAssembly function. |
|
List registered functions. |
Write and registration options#
--appendonwriteadds records instead of replacing data.--on-violation refuse|exclude|warnonwritesays what to do with rows that break a row rule (see Rows that break a contract). The default,refuse, writes nothing when any row breaks a rule.excludewrites only the rows that pass and requires--excluded PATH, where the set-aside rows are written as Parquet with a_violationscolumn.warnwrites every row.--type COLUMN=TYPEonregisterorwriteoverrides CSV type inference. Repeat it for multiple columns.--revokeonpublishwithdraws the specified audience.
Query options#
Option |
Effect |
|---|---|
|
Human-readable table; the default. |
|
One JSON object per row. |
|
Arrow IPC file. |
|
Parquet file. |
|
Write results to a file instead of standard output. |
|
Print query metadata as JSON to standard error. |
|
Show the physical plan without executing it; intended for operators. |
|
Leave out rows that break a row rule and note how many per rule on standard error; the default. |
|
Refuse the query when the data holds any row that breaks a row rule. |
SQL EXPLAIN is refused through the ordinary query interface. --explain is a separate operator action and can expose implementation details.
Caller options#
query and describe accept --caller FILE for a YAML caller document. Explicit flags override file values.
Flag |
Context supplied |
|---|---|
|
Caller ID. |
|
Organisation or tenant name. |
|
Purpose of the query. |
|
Role; repeat for several roles. Supplied roles replace the file’s role list. |
|
Integer clearance level. |
|
Tier name. |
|
Classification name. |
|
Query time in RFC 3339 format; defaults to the current time. |
Without a caller file or overrides, the CLI uses ID cli, an empty tenant and an empty purpose. Contracts that require specific values may refuse that caller.
Exit codes#
Code |
Meaning |
|---|---|
|
The command succeeded; writes and validation passed deny-level checks. |
|
Query or describe refusal, a write refused for rows that break a row rule, or a write/validation verdict that is not valid. |
|
Other errors, such as invalid arguments, compilation, missing data or execution failures. |
SQL behaviour#
peQL uses DataFusion SQL and accepts one query at a time. Select from a registered contract by name, quoting names containing /, for example "sales/orders".
Joins, aggregates and subqueries operate over the exposed contract views. DDL, DML, COPY, SET, SQL EXPLAIN and multiple statements are refused. Catalog/schema-qualified table references are not contract names; use the whole contract name as one quoted identifier.
Rows that break a contract#
A row breaks its contract when it fails an assert whose on_fail is drop or deny. An assert with on_fail: report only counts its failures; no row breaks it. Guarantees are rules about the whole dataset, not rows, and are decided only by validate.
Reads. A read never returns a row that breaks its contract. The read’s on_violation (OnReadViolation in Rust) chooses what happens when the data holds such rows:
Mode |
Effect |
|---|---|
|
The default. The contract’s view leaves the rows out, and the envelope’s |
|
The read is refused with |
There is no mode that returns breaking rows. The counts come from the dataset’s manifest: they cover the whole dataset, not only the rows a query’s own filters would have reached. A refuse read is therefore refused when the dataset holds any breaking row. Caller-level rules (decide) are checked first and refuse a read whatever its mode. Columns a contract withholds stay withheld, and masked columns stay masked, in either mode.
Writes. A write’s on_violation (OnWriteViolation in Rust) chooses what happens to the rows it is given that break a row rule:
Mode |
Effect |
|---|---|
|
The default. Nothing is committed; the write fails with |
|
Only the rows that pass are committed. The others are returned to the writer in the contract’s row schema plus a |
|
Every row is committed. The verdict is not valid when a deny-level assert fails, and the report counts the breaking rows per rule. Reads leave those rows out. |
A write evaluates only row rules, over its own rows. Engine::compact rewrites rows as stored and neither refuses nor sets any aside.
Validation and write reports#
A write report contains rows_written, on_violation, violations, rows_excluded, files, verdict, table and, for an Iceberg table, snapshot. violations maps each row rule to the number of rows the write was given that broke it: set aside under exclude, committed under warn. A row that breaks two rules is counted under both. rows_excluded is the number of rows set aside rather than committed. table is the data’s row_count and per-column null_counts after the write, from its manifest, or null while the manifest is not recorded. files lists the files the write added; verdict is the contract’s row rules over the rows written, with a hash over those files. The dataset’s manifest is updated from the write’s facts without reading earlier files.
The verdict includes valid, row_count, failures, breached, guarantees, stats and data_hash. failures maps assertion IDs to failing-row counts. valid can be true when drop-level or report-only checks fail. A write’s verdict covers only its rows and row rules, so its guarantees is empty; validate decides each dataset guarantee over the whole data, and the manifest keeps each one’s last decision (holds, snapshot_id, decided_at) until the next validate.
Query envelope#
Field |
Meaning |
|---|---|
|
The caller’s id, tenant and purpose, as the engine was told them. |
|
Names, versions, hashes, decision rules, annotations, active result rules and use of stored calculations. Each contract’s |
|
Number of returned rows. |
|
Active minimum group size, if any. |
|
Epsilon this query charged, per budget. |
|
Remaining amounts for budgets charged by this query. An empty map is not a full ledger balance. |
|
Scan/release row counts, scanned Arrow bytes, file bytes read and pruning counters. |
|
Query and result SHA-256 hashes plus a timestamp; not a signature. With a signer configured, |
|
Identifier of the corresponding audit entry. |
|
Whether stored result batches were returned. |
Common errors#
Error |
What to check |
|---|---|
|
Contract syntax, expressions, column names and types. |
|
Registration and publication to the caller’s tenant. An invisible contract has the same error as an absent one. |
|
The named caller-level rule and supplied context. |
|
Whether the contract has data and a validation manifest. |
|
The deny-level guarantees the dataset failed when |
|
Rows that break the named row rules, with how many broke each: a write refused them ( |
|
The named dataset requirement, such as freshness or a missing-value limit. |
|
Spending and the limit for that caller’s named budget. |
|
Whether the SQL is a single supported read-only query. |
|
The accompanying message: input, planning, execution or storage failed. |
|
The configured envelope signer: it refused or did not answer, so the query returns nothing. |
|
A contract scan is missing its required execution gate; report this as an engine/integration issue. |
In Rust, PeqlError::is_refusal() includes UnknownContract, Denied, NotServable, Violated, GuaranteeFailed, BudgetExhausted and Refused. NotWritten is a separate failure. Python maps the refusal group to peql.Refused.
Workspace files#
Location |
Contents |
|---|---|
|
Versioned contracts (document, functions and compiled bytes) and publication records. |
|
Registered WebAssembly modules and metadata. |
|
Budget limits and spending. |
|
Query-attempt records, one JSON object per line. |
|
Per-contract dataset manifests beside the bound data. |
Keep the workspace state and dataset files together when moving or backing up a workspace. Single-file Parquet bindings can be read; peQL’s write path requires a directory binding.
Rust write and read API#
Item |
Shape |
|---|---|
|
Returns |
|
Starts a write delivered in parts. |
|
Returns |
|
Returns the |
|
|
|
|
|
|
|
|
|
|
Build features#
The default Rust build has no optional features enabled. flight adds the Flight SQL service and s3 the S3 store for object-store bindings. lance adds the Lance dependencies; the provider is exposed on Unix and needs protoc to build.
See Optional integrations for integration behaviour.