Case study 04 / ML Engineering · Software Engineering
ML features without future leakage.
A Go feature store with historical training joins, Parquet offline storage, and Redis online serving.
The problem
A model can look excellent offline if its training features contain information that only became available after a prediction event. How can a feature store prevent that leakage?
What I built
Built a YAML feature registry, event-time materialization of hourly driver snapshots into Parquet, online serving of each driver’s latest snapshot from Redis, and an HTTP API for online and historical retrieval. A separate PySpark job demonstrates batch aggregation on larger inputs.
How it works
The registry describes entities, feature views, and TTLs. Materialization turns completed trips into hourly snapshots, keeps the history in Parquet, and publishes each driver’s latest closed snapshot to Redis. Historical retrieval picks, for each event, the newest snapshot at or before the event and within the TTL.
- Feature registry
- Materialization
- Parquet / Redis
- Training / inference
Engineering decisions
Time is part of correctness
Historical joins reject snapshots after the event and snapshots older than the 24-hour TTL. An event with no eligible snapshot keeps missing features rather than borrowing a future value.
Make serving paths explicit
Separate online lookup and historical join endpoints keep low-latency inference retrieval distinct from training-data construction.
Test against a reference
38 test cases cover registry validation, Parquet round trips, and join rules. A seeded randomized test compares the batched join with a naive reference on shuffled data, equal timestamps, gaps, and exact TTL boundaries. CI fails if any test is skipped.
Results & evidence
Which snapshot the historical join picks
Core guarantee
No future rows
Enforced by explicit timestamp and TTL checks in the historical join and checked against a naive reference implementation; an implementation property, not a performance benchmark.
Storage paths
Offline + online
Parquet for historical retrieval and Redis for online lookup, with a shared registry.
Results are documented in the linked project artifacts. They have not been independently reproduced for this portfolio.
Limits & lessons
Each historical request still scans the whole Parquet file in batches, so query cost grows with history size. The API is a local development server without authentication. The Spark timing (2.29–2.43 s for 9.55 million rows on an Apple M4) measures batch aggregation, not historical-join latency or online-serving capacity.
Training-serving consistency requires explicit time semantics, not just matching column names.