Skip to main content

Standard.to_validate()

Compile the standard into a validation plan for a table, without running it.

Usage

Source

Standard.to_validate(
    data,
    tbl_name=None,
)

This method makes the Validate object that apply() makes for each table: it has the standard’s steps, thresholds, and governance metadata (owner, consumers, and version), and a label of the form "Standard: <name> v<version>". A step whose column selector matches none of the table’s columns will be not applicable when the validation is interrogated (see the Steps That Don’t Apply section of Standard).

Use it to add checks that only one table needs, or to set Actions, before calling interrogate(). The standard itself isn’t changed.

Parameters

data: IntoDataFrame

The table to validate. Any table type that Validate takes can be used.

tbl_name: str | None = None
The name of the table, for the validation’s tbl_name=.

Returns

Validate
A Validate object with the standard’s steps, not yet interrogated.

Raises

TypeError
If a step’s arguments don’t fit its validation method (e.g., a misspelled argument name), since step arguments are only checked when the standard is compiled.

Examples

Let’s compile a standard for one table and add a check of its own before interrogating.

import pointblank as pb
import polars as pl

id_standard = pb.Standard(
    name="id-columns",
    steps=[pb.Step("col_vals_not_null", columns=pb.ends_with("_id"))],
)

orders = pl.DataFrame(
    {"order_id": [1, 2, 3], "customer_id": [7, None, 9], "amount": [20.0, 5.5, -1.0]}
)

(
    id_standard.to_validate(orders, tbl_name="orders")
    .col_vals_ge(columns="amount", value=0)
    .interrogate()
)
Pointblank Validation
Standard: id-columns
Polarsorders
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_not_null
col_vals_not_null()
order_id — ✓ 3 3
1.00
0
0.00
— — — —
#4CA64C66 2
col_vals_not_null
col_vals_not_null()
customer_id — ✓ 3 2
0.67
1
0.33
— — —
#4CA64C66 3
col_vals_ge
col_vals_ge()
amount 0 ✓ 3 2
0.67
1
0.33
— — —

The selector of the standard’s step finds the two ID columns, so the step expands into two steps, and the missing customer ID fails the second. The third step, which only this table has, flags the negative amount.