Skip to main content

Standard.apply()

Validate every table of a source that the standard applies to.

Usage

Source

Standard.apply(
    source,
    applies_to=None,
)

This method finds the tables of a source, selects them with the applies_to= selector, and validates each one with the standard’s steps (as validate() does). Each table gets a validation of its own, named with the table’s name, so a table that fails doesn’t stop the others from being validated. The results come back in a StandardResult, which shows all the validations in one report and tells which tables failed.

The tables are found when the method is called, so applying a standard on a schedule validates new tables as they appear.

Parameters

source: Any

The tables: a dictionary of names to tables, an Ibis connection or a connection string, a directory, a glob pattern, or a list of files (see the Sources of Tables section of Standard).

applies_to: TableSelector | None = None
A table selector that’s used instead of the standard’s applies_to=. If neither is given, every table of the source is validated.

Returns

StandardResult
The validations of the tables, in the order of the source. A table that couldn’t be read is in its errors instead.

Raises

TypeError

If source= isn’t one of the kinds of sources, or a step’s arguments don’t fit its validation method.

FileNotFoundError
If source= is a path that doesn’t exist.

Warns

UserWarning
If no table of the source is selected (the result is then empty).

Examples

Let’s set up a DuckDB database with a few tables in two schemas: the tables of the default schema (main) are raw extracts, and the marts schema has the tables that analysts use.

import ibis
import pointblank as pb
import polars as pl

con = ibis.duckdb.connect()
con.raw_sql("CREATE SCHEMA marts")

con.create_table("raw_events", pl.DataFrame({"event_id": [1, 1, 2]}))
con.create_table(
    "dim_customers",
    pl.DataFrame({"customer_id": [1, 2, 3], "region": ["EU", "US", None]}),
    database="marts",
)
con.create_table(
    "dim_products",
    pl.DataFrame({"product_id": [10, 11], "category": ["toys", "books"]}),
    database="marts",
)
con.create_table(
    "fct_sales",
    pl.DataFrame({"customer_id": [1, 2, 2], "product_id": [10, 10, 11]}),
    database="marts",
)

con.list_tables(database="marts")
['dim_customers', 'dim_products', 'fct_sales']

Our standard for dimension tables says that each must have unique rows and that its columns are complete. It applies to the tables of the marts schema whose names start with "dim_".

dim_standard = pb.Standard(
    name="dimension-tables",
    version="2.1.0",
    steps=[
        pb.Step("rows_distinct"),
        pb.Step("col_vals_not_null", columns=pb.everything()),
    ],
    applies_to=pb.in_schema("marts") & pb.tbl_starts_with("dim_"),
)

result = dim_standard.apply(con)

result
Standard: dimension-tables v2.1.0
FAIL
TABLES
2
PASS
1
FAIL
1
Health Score
93.33%
2026-12-04 20:42:53 UTC
STEPS
PASS
FAIL
Health Score
1DuckDBmarts.dim_customersStandard: dimension-tables v2.1.0
2026-12-04 20:42:53 UTC
3
2
1
88.89%
Standard: dimension-tables v2.1.0
DuckDBmarts.dim_customers
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
rows_distinct
rows_distinct()
ALL COLUMNS — ✓ 3 3
1.00
0
0.00
— — — —
#4CA64C 2
col_vals_not_null
col_vals_not_null()
customer_id — ✓ 3 3
1.00
0
0.00
— — — —
#4CA64C66 3
col_vals_not_null
col_vals_not_null()
region — ✓ 3 2
0.67
1
0.33
— — —
Version: 2.1.0
2DuckDBmarts.dim_productsStandard: dimension-tables v2.1.0
2026-12-04 20:42:53 UTC
3
3
0
100%
Standard: dimension-tables v2.1.0
DuckDBmarts.dim_products
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
rows_distinct
rows_distinct()
ALL COLUMNS — ✓ 2 2
1.00
0
0.00
— — — —
#4CA64C 2
col_vals_not_null
col_vals_not_null()
product_id — ✓ 2 2
1.00
0
0.00
— — — —
#4CA64C 3
col_vals_not_null
col_vals_not_null()
category — ✓ 2 2
1.00
0
0.00
— — — —
Version: 2.1.0

The standard found the two dimension tables, and the report has a section for each. The dim_customers table has a missing region, so it fails:

result.failing_tables()
['marts.dim_customers']

The same standard can be applied with another selector, for instance to check the uniqueness of the raw tables too:

dim_standard.apply(con, applies_to=pb.tbl_starts_with("raw_")).failing_tables()
['raw_events']

The raw_events table has a duplicate row, so it fails the first step.