A Proof of Concept (POC) for a configuration-driven Spark application that executes Data Quality (DQ) and Cleansing rules in a multi-stage pipeline, capturing detailed row-level results without data loss.
- Config-Driven: Define pipelines using YAML files (no code changes needed for rule updates).
- Row-Level Tracking: Appends a
_dq_resultscolumn to tracking pass/fail status for every rule on every row. - Multi-Stage: Chain together DQ checks, Cleansing sets, and re-verification steps.
- Extensible: Easily add new rules in Python.
- GUI Prototype: A React Flow-based visual editor to design pipelines.
├── config/ # Pipeline definitions (YAML)
├── data/ # Sample input data (CSV)
├── gui/ # React-based Visual Editor
├── src/
│ ├── engine.py # Pipeline Orchestrator
│ ├── dq_rules.py # Data Quality Logic (NotNull, Regex, Min/Max, etc.)
│ ├── cleanse_rules.py# Cleansing Logic (Trim, Lowercase)
│ └── dq_utils.py # Result capture utilities
└── main.py # Entry point
- Prerequisites: Python 3.8+, pip, Java 8/11/17 (for Spark).
- Installation:
pip install pyspark pyyaml
Uses config/pipeline_def.yaml on data/customers.csv.
python main.pyOutput is saved to results.txt.
Uses config/pipeline_complex.yaml on data/customers_large.csv. Includes numeric checks, set validation, and more.
python main_complex.pyOutput is saved to results_complex.txt.
The pipeline is defined in YAML:
stages:
- name: "Stage Name"
type: "dq" # or "cleanse"
rules:
- id: "unique_rule_id"
type: "check_not_null" # Must match function in dq_rules.py
column: "column_name"
# ... other params specific to the ruleData Quality (src/dq_rules.py):
check_not_null: Fail if null.check_regex: Fail if doesn't match pattern.check_min/check_max: Numeric bounds.check_in_set: Value must be in list.check_length: String length bounds.
Cleansing (src/cleanse_rules.py):
clean_trim: Remove whitespace.clean_lowercase: Convert to lowercase.
A drag-and-drop interface is available in the gui/ directory.
- Navigate to
gui/:cd gui - Install dependencies:
npm install
- Start server:
npm run dev
- Open
http://localhost:5173in your browser. - Design your pipeline and click Download YAML.
To add a new rule:
- Define the function in
src/dq_rules.pyorsrc/cleanse_rules.py. - Register it in the map in
src/engine.py. - Use it in your YAML config.