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()
)Standard.to_validate()
Compile the standard into a validation plan for a table, without running it.
Usage
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.
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.