# pysparky_data_quality

*module*

Composable data-quality rules for native PySpark DataFrames.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/__init__.py#L1-L1)

## pysparky_data_quality.CheckResult

*class* · *dataclass*

```python
class CheckResult
```

Re-exported from: `pysparky_data_quality.report`

Serializable status and metrics for one named validation check.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L18-L111)

### pysparky_data_quality.CheckResult.check_id

*attribute* · *instance attribute*

```python
check_id: str
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L22-L22)

### pysparky_data_quality.CheckResult.error_message

*attribute* · *class attribute* · *instance attribute*

```python
error_message: str | None = None
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L29-L29)

### pysparky_data_quality.CheckResult.error_type

*attribute* · *class attribute* · *instance attribute*

```python
error_type: str | None = None
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L28-L28)

### pysparky_data_quality.CheckResult.metrics

*attribute* · *class attribute* · *instance attribute*

```python
metrics: tuple[tuple[str, MetricValue], ...] = ()
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L25-L25)

### pysparky_data_quality.CheckResult.null_policy

*attribute* · *class attribute* · *instance attribute*

```python
null_policy: str | None = None
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L26-L26)

### pysparky_data_quality.CheckResult.scope

*attribute* · *instance attribute*

```python
scope: Scope
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L23-L23)

### pysparky_data_quality.CheckResult.status

*attribute* · *instance attribute*

```python
status: CheckStatus
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L24-L24)

### pysparky_data_quality.CheckResult.violations

*attribute* · *class attribute* · *instance attribute*

```python
violations: tuple[str, ...] = ()
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L27-L27)

### pysparky_data_quality.CheckResult.from_error

*method* · *classmethod*

```python
def from_error(check_id: str, scope: Scope, error: Exception) -> CheckResult
```

Create an execution-error result without collecting input rows.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L85-L95)

### pysparky_data_quality.CheckResult.from_outcome

*method* · *classmethod*

```python
def from_outcome(check_id: str, scope: Scope, outcome: ExpectationOutcome) -> CheckResult
```

Convert an already evaluated dataset/schema outcome without I/O.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L68-L83)

### pysparky_data_quality.CheckResult.to_dict

*method*

```python
def to_dict() -> dict[str, object]
```

Return this result as JSON-serializable built-in values.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L97-L111)

## pysparky_data_quality.DataValidator

*class* · *dataclass*

```python
class DataValidator
```

Re-exported from: `pysparky_data_quality.validation`

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.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L60-L215)

### pysparky_data_quality.DataValidator.rules

*property*

```python
rules: tuple[ValidationRule, ...]
```

Rules in their declared evaluation and reporting order.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L89-L91)

### pysparky_data_quality.DataValidator.annotate

*method*

```python
def annotate(dataframe: DataFrame) -> DataFrame
```

Add 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.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L97-L132)

### pysparky_data_quality.DataValidator.split

*method*

```python
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.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L134-L150)

### pysparky_data_quality.DataValidator.validate

*method*

```python
def validate(dataframe: DataFrame) -> ValidationReport
```

Evaluate 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.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L152-L215)

### pysparky_data_quality.DataValidator.with_rule

*method*

```python
def with_rule(rule: ValidationRule) -> DataValidator
```

Return a new validator with rule appended, preserving this instance.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L93-L95)

## pysparky_data_quality.ValidationReport

*class* · *dataclass*

```python
class ValidationReport
```

Re-exported from: `pysparky_data_quality.report`

Immutable versioned collection of row, dataset, and schema results.

Version 1 uses JSON scalar metrics, ordered checks, and no raw row samples.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L114-L189)

### pysparky_data_quality.ValidationReport.checks

*attribute* · *class attribute* · *instance attribute*

```python
checks: tuple[CheckResult, ...] = ()
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L121-L121)

### pysparky_data_quality.ValidationReport.schema_version

*attribute* · *class attribute* · *instance attribute*

```python
schema_version: int = 1
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L122-L122)

### pysparky_data_quality.ValidationReport.passed

*property*

```python
passed: bool
```

Whether the report contains no failed or errored checks.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L149-L151)

### pysparky_data_quality.ValidationReport.status

*property*

```python
status: ReportStatus
```

Return aggregate status, preserving execution errors distinctly.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L140-L146)

### pysparky_data_quality.ValidationReport.combine

*method* · *classmethod*

```python
def combine(*reports: ValidationReport) -> ValidationReport
```

Combine reports in argument order, rejecting duplicate check IDs.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L178-L181)

### pysparky_data_quality.ValidationReport.from_errors

*method* · *classmethod*

```python
def from_errors(errors: Mapping[str, tuple[Scope, Exception]]) -> ValidationReport
```

Compose captured execution errors without retrying the checks.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L166-L176)

### pysparky_data_quality.ValidationReport.from_outcomes

*method* · *classmethod*

```python
def from_outcomes(outcomes: Mapping[str, tuple[Scope, ExpectationOutcome]]) -> ValidationReport
```

Compose named, already evaluated expectation outcomes without I/O.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L153-L164)

### pysparky_data_quality.ValidationReport.to_dict

*method*

```python
def to_dict() -> dict[str, object]
```

Return a stable versioned structure suitable for JSON encoding.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/report.py#L183-L189)

## pysparky_data_quality.ValidationRule

*class* · *dataclass*

```python
class ValidationRule
```

Re-exported from: `pysparky_data_quality.validation`

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.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L19-L57)

### pysparky_data_quality.ValidationRule.condition

*attribute* · *instance attribute*

```python
condition: Column
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L30-L30)

### pysparky_data_quality.ValidationRule.name

*attribute* · *instance attribute*

```python
name: str
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L29-L29)

### pysparky_data_quality.ValidationRule.null_policy

*attribute* · *class attribute* · *instance attribute*

```python
null_policy: NullPolicy = 'fail'
```

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L31-L31)

### pysparky_data_quality.ValidationRule.predicate

*method*

```python
def predicate() -> Column
```

Return a boolean Column with the configured NULL policy applied.

[View source](https://github.com/PySparky/pysparky-data-quality/blob/46facb9e156e26dfd76fa534c81f75749c7879d8/src/pysparky_data_quality/validation.py#L52-L57)

**Modules**

- `pysparky_data_quality.expectations`
- `pysparky_data_quality.report`
- `pysparky_data_quality.rules`
- `pysparky_data_quality.validation`
