Point-in-Time Correct Join of Labels and Feature History

Last updated: November 29, 2026

Quick Overview

Given labeled events (entity, label time) and a history of feature observations (entity, observation time, value), return for each label the most recent value observed at or before the label time, optionally ignoring values older than a maximum age.

Chalk
Coding & Algorithms
Machine Learning Engineer
Chalk
November 29, 2026
Machine Learning Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given labeled events (entity, label time) and a history of feature observations (entity, observation time, value), return for each label the most recent value observed at or before the label time, optionally ignoring values older than a maximum age.

Chalk's offline queries promise that each training row sees exactly the feature values production would have seen at that moment, which prevents label leakage. The interviewer checks that you avoid future data, handle ties and staleness deliberately, and do better than a nested loop.

What the Interviewer Expects
  • Never returns an observation timestamped after the label
  • Groups by entity and sorts once, then uses binary search per label
  • Defines tie behavior at equal timestamps (inclusive, later write wins)
  • Supports a max age so very stale values become null
  • Preserves the original label order in the output
  • Explains why this matters for training-serving consistency
Key Topics to Cover
as-of join
binary search
label leakage
point-in-time correctness
training data
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you do this when both inputs are too large for memory and live in Parquet on S3?
  • If observation timestamps are when the source row changed but the data landed in the warehouse hours later, which timestamp should the join use?
  • How would you join ten features with different histories in one pass?
  • How would you test that a pipeline is leakage free?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Labels: (entity, label_ts). Observations: (entity, obs_ts, value), unsorted, possibly with duplicate timestamps. For each label, pick the last observation with obs_ts <= label_ts. If max_age i...

High-Level Design

Bucket observations by entity, sort each bucket by time (a stable sort keeps later inserted rows after earlier ones at the same timestamp, so the last one wins ties), and keep a parallel list of times...


Submit Your Answer
Markdown supported

Related Questions