⚠️ WARNING: Validation step '1' exceeded threshold!
❌ ERROR: Critical validation failure in step '2'!
This requires immediate attention.
Validation with Actions
Configure actions to trigger when validation thresholds are exceeded, such as logging warnings or errors.
import pointblank as pb
def log_warning():
"""Custom action to log validation warnings"""
= pb.get_action_metadata()
metadata print(f"⚠️ WARNING: Validation step '{metadata['step']}' exceeded threshold!")
def log_error():
"""Custom action to log validation errors"""
= pb.get_action_metadata()
metadata print(f"❌ ERROR: Critical validation failure in step '{metadata['step']}'!")
print(f" This requires immediate attention.")
= (
validation
pb.Validate(=pb.load_dataset(dataset="nycflights", tbl_type="polars"),
data="Validation with actions"
label
)
.col_vals_between(="distance",
columns=100, right=2000,
left=pb.Thresholds(warning=0.1), # Allow 10% failures before warning
thresholds=pb.Actions(warning=log_warning),
actions="Column 'distance' range check."
brief
)
.col_vals_gt(="air_time",
columns=25,
value=True,
na_pass=pb.Thresholds(error=200), # Allow only 200 failures before error
thresholds=pb.Actions(error=log_error),
actions="Column 'origin' check for minimum value."
brief
)
.col_vals_not_null(="carrier",
columns=(1, 0.05), # No tolerance for null values
thresholds=pb.Actions(warning=log_warning, error=log_error),
actions="Column 'carrier' completeness check."
brief
)
.interrogate()
)
validation
Preview of Input Table
PolarsRows336,776Columns18 |
||||||||||||||||||