pysparky_data_quality.validation
Immutable definitions and ordered collections of row validation rules.
Attributes
| Name | Description |
|---|---|
NullPolicy | No description. |
Classes
| Name | Description |
|---|---|
DataValidator | Immutable, ordered collection of uniquely named validation rules. |
ValidationRule | A named boolean Column expression with an explicit SQL NULL policy. |
DataValidatorclassdataclass#
class DataValidator(rules: Iterable[ValidationRule] = ())Immutable, ordered collection of uniquely named validation rules.
The registry stores expressions only. It does not accept a DataFrame, create a SparkSession, or trigger Spark work.
rulesproperty#
rules: tuple[ValidationRule, ...]Rules in their declared evaluation and reporting order.
annotatemethod#
def annotate(dataframe: DataFrame) -> DataFrameAdd one boolean result column per rule without running an action.
Each result column uses its rule’s name. Existing columns are preserved in order. Names that collide under case-insensitive comparison are rejected so behavior does not depend on Spark’s resolver setting.
splitmethod#
def split(dataframe: DataFrame) -> tuple[DataFrame, DataFrame]Return lazy (valid, invalid) frames with the original schema.
A row is valid only when every normalized rule predicate is true. With no rules, the empty conjunction is true and all rows are valid. The two outputs are mutually exclusive and collectively exhaustive.
validatemethod#
def validate(dataframe: DataFrame) -> ValidationReportEvaluate row rules in one explicit action and return a report.
Each rule result includes total and failed row counts. Empty validators
return an empty report without scanning the DataFrame. Spark failures
become error results; invalid Python definitions still raise.
with_rulemethod#
def with_rule(rule: ValidationRule) -> DataValidatorReturn a new validator with rule appended, preserving this instance.
ValidationRuleclassdataclass#
class ValidationRule(name: str, condition: Column, null_policy: NullPolicy = 'fail')A named boolean Column expression with an explicit SQL NULL policy.
condition must be a boolean PySpark Column. Its raw SQL result may be
true, false, or NULL. Calling predicate maps a NULL result to false by
default, or to true when null_policy is "pass". This constructs a
lazy Column expression and performs no Spark action.
conditionattributeinstance attribute#
condition: Columnnameattributeinstance attribute#
name: strnull_policyattributeclass attributeinstance attribute#
null_policy: NullPolicy = 'fail'predicatemethod#
def predicate() -> ColumnReturn a boolean Column with the configured NULL policy applied.