A Standard is a reusable set of validation steps for a whole group of tables: all the tables in a database schema, every table whose name follows a pattern, or every file in a directory. Where a Contract describes one particular table, a standard describes what every table of a kind should look like. “Every email column holds valid addresses”, “every table has unique rows”, or “every *_id column is complete” are typical rules of a standard.
Calling apply() with a source (a database, a directory of files, or a dictionary of tables) finds the tables that the applies_to= selector chooses, validates each one separately with the steps, and collects the results in a StandardResult. Since the tables are found anew each time, applying the standard again after new tables appear validates them too, with no change to the standard.
The steps can use column selectors (like matches() or ends_with()), which are resolved against the columns of each table. So columns=pb.matches("email") checks the email column of one table and the customer_email and billing_email columns of another. A step whose selector matches none of a table’s columns doesn’t apply to that table (see Steps That Don’t Apply below).
Parameters
name:str
A short, unique name for the standard (e.g., "email-fields"). It’s part of the label of each table’s validation. It must be a non-empty string.
steps:list[Step] | Steps=list()
The validation steps, as a list of Step objects (e.g., pb.Step("col_vals_not_null", columns=pb.matches("_id$"))) or as a Steps object. Any validation method can be used. The steps run in order on each table.
applies_to:TableSelector | None=None
A table selector that chooses the tables of a source to validate, such as tbl_matches(), tbl_starts_with(), or in_schema(), possibly combined with &, |, -, and ~. The applies_to= argument of apply() takes precedence over it. If neither is given, every table of the source is validated.
version:str | None=None
A version string for the standard, such as "1.0.0". It’s added to the label of each table’s validation (e.g., "Standard: email-fields v1.0.0") and recorded in its governance metadata.
owner:str | None=None
The person or team responsible for the standard. It’s recorded in the governance metadata of each table’s validation.
consumers:str | list[str] | None=None
Who depends on the tables meeting the standard, as a string or a list of strings. It’s recorded in the governance metadata of each table’s validation.
description:str | None=None
An optional longer description of the standard’s purpose. It’s kept with the standard but doesn’t appear in validation reports.
The Thresholds of each table’s validation (or any of the shorthands that Validate(thresholds=) takes), which set when a failing step reaches the ‘warning’, ‘error’, or ‘critical’ level. Steps can have thresholds of their own.
a dictionary of names to tables (any table that Validate takes, or paths to CSV and Parquet files)
an Ibis connection to a database (e.g., ibis.duckdb.connect("warehouse.ddb")), or a connection string without a ::table part (e.g., "duckdb:///warehouse.ddb")
a directory, whose .csv and .parquet files are the tables
a glob pattern (e.g., "data/marts/*.parquet") or a list of paths to files
A table of a directory or a list of files is named by the file name without its extension (e.g., orders for orders.parquet), and files are read lazily (as Polars LazyFrames), so the tables of a large source aren’t all held in memory at once. The tables of a database are those of its default schema, plus the tables of every schema named with in_schema() in the selector. A table outside the default schema is named with its schema (e.g., "analytics.customers").
Steps That Don’T Apply
A standard is meant for tables with different columns, so a step whose column selector matches none of a table’s columns is not applicable to it, rather than an error. The step is kept in the table’s validation as an inactive step with a “Not applicable” note, so the report shows that it was considered. Inactive steps don’t count toward all_passed() or the health and dimension scores. A table that none of the steps apply to is listed by not_applicable_tables().
A column named with a string is required, though: if a table doesn’t have it, the step can’t be evaluated, which counts as a failure (as it would in any validation). So use a selector for a column that some tables don’t have, and a name for a column that every table must have.
Examples
Let’s write a standard for every column of an email address, wherever it appears: an address must be present and must look like an address. The matches() selector finds the email columns of each table, whatever they’re called.
Here are three tables, two with email columns. The orders table has a missing address and a malformed one, and the products table has no email column at all.
Step 1(not_applicable) Not applicable — The column expression Matches(pattern='email', case_sensitive=False) does not resolve to any columns.
Step 2(not_applicable) Not applicable — The column expression Matches(pattern='email', case_sensitive=False) does not resolve to any columns.
The result has a validation for each table, with all of them in one report. The customers table passes, the orders table has a failing test unit in each step, and the steps of the products table are inactive, since they don’t apply to it. The result can also be checked in code: