This project demonstrates an end-to-end data engineering pipeline that ingests vote data, processes it incrementally, and identifies anomalous (outlier) weeks using SQL-based analytics.
The solution is designed with a production mindset, ensuring idempotency, data consistency, and clean analytical outputs.
JSON Data → Staging Table → Deduplication → Final Table (votes) → Outlier Analysis
- Python
- DuckDB (OLAP database)
- SQL
- Docker (for execution environment)
-
Reads JSONL vote data
-
Loads data into staging table
-
Applies deduplication using window functions
-
Performs upsert using
INSERT OR REPLACE -
Ensures:
- Incremental loads
- No duplicate records
- Idempotent execution
- Aggregates votes weekly
- Calculates average votes per week
- Identifies outliers using:
[ |1 - (x_i / \bar{x})| > 0.2 ]
-
Outputs:
- Year
- Week Number
- Vote Count
poetry run exercise ingest-data
poetry run exercise run-outliers
poetry run exercise check-ingestion
poetry run exercise check-outliers
- Idempotent ingestion pipeline
- Incremental data processing
- Clean and deduplicated analytical table
- SQL-based anomaly detection
- Lightweight and efficient (DuckDB)
- Add data quality checks (null validation, schema enforcement)
- Partitioning for large-scale datasets
- Integration with cloud storage (S3 / ADLS)
- Scheduling using Airflow
Idis unique for each vote- Latest record is determined by
creation_date - Input data is well-structured JSON
- All vote types are treated equally
Mohit Singh Senior Data Engineer