Engineering Interview Practice

ML system design interview: a point-in-time join

Practice an ML system design interview with a fictional feature history, a point-in-time selection contract and runnable Python checks for late corrections.

An open wooden card file holds blank index cards beside a separate stack and a cobalt-blue card.
On this page
  1. Define the historical input you want to reconstruct
  2. Inspect the seven-row history before choosing a value
  3. Specify eligibility, ranking and invalid input
  4. Run the complete Python reference
  5. Trace all ten cutoff cases
  6. Connect the contract to a real ML design discussion
  7. Frequently asked questions
  8. Sources

For an ML system design interview, define which feature version was usable when a prediction was requested. A measurement can have an old event timestamp while its corrected value becomes available later. Work through a point-in-time join that checks both timestamps before choosing a version.

Define the historical input you want to reconstruct

A feature is an input to a model. A point-in-time join associates a historical prediction request with feature history at its cutoff. Here, the objective is strict replay of recorded version availability on one assumed serving-input path.

Scikit-learn’s leakage guidance describes the problem of using information unavailable at prediction time. Databricks’ point-in-time join documentation, updated September 11, 2026, explains historical timestamp-key lookups and configurable lookback windows. Those concepts motivate this exercise; the following data and rules are author-defined.

The fictional queue predictor uses observed counts. event_tick marks when a count was measured. available_tick marks when that exact version first became usable on the assumed prediction-input path. All ticks share one invented integer clock. They make no claim about real distributed-clock synchronization.

Use this task within a broader system design interview rehearsal. No model, personal data or accuracy result is supplied.

Inspect the seven-row history before choosing a value

Every row below is invented. R labels identify rows for discussion; they are not dictionary fields. A revision fully replaces an earlier version of the same event, rather than adding a delta.

Row Entity Feature Event tick Available tick Revision Value
R1 queue-a backlog 10 11 1 4
R2 queue-a backlog 10 18 2 9
R3 queue-a backlog 14 16 1 6
R4 queue-a backlog 14 16 2 7
R5 queue-a workers 9 9 1 0
R6 queue-b backlog 12 12 1 100
R7 queue-a workers 13 13 1 null

Request queue-a’s backlog at cutoff 12. Filtering only event time and taking the greatest event/revision pair selects R2: event 10, revision 2, value 9. But R2 contains newly usable information at tick 18, unavailable at 12. Under this replay contract, R1 supplies value 4.

A later materialization, recomputation or backfill is not automatically leakage. Its computation date alone does not establish future-information use. Recomputing historically valid inputs requires a separate, explicit policy.

Specify eligibility, ranking and invalid input

Keep the in-memory history fixed for the duration of each call. The complete contract is:

  • Inputs: a list of dictionaries with exactly the six fields shown in the code. Entity and feature identifiers are case-sensitive, nonempty strings without surrounding whitespace. Ticks and cutoff are exact nonnegative Python integers; revisions are integers of at least one. Booleans and floats are rejected. Values are exact nonnegative integer counts or None.
  • Validation: inspect every row, including unrelated and future rows. Malformed keys, types, ranges or queries raise ValueError. These observed counts require availability at or after their event. Python’s missing or unexpected call arguments still raise TypeError.
  • Identity: (entity, feature, event_tick, revision) identifies one version. Reject repeated identities, even identical duplicates. Revisions order versions within the same event only.
  • Selection: match entity and feature exactly. Require both event_tick <= cutoff and available_tick <= cutoff. The boundary is inclusive: availability at that tick means already usable. Choose the largest (event_tick, revision) among eligible rows.
  • Output: return a new copy of the full selected dictionary, or outer None for no eligible record. Preserve zero and a selected record whose value is None. Do not fall back to an older non-null value, borrow another feature or mutate the input. Primitive fields make a shallow copy sufficient here.

Because valid observed counts require available_tick >= event_tick, the event cutoff is redundant for this fixture’s eligibility. It remains explicit in the contract. Event time still controls ranking: the latest arrival can describe an older event.

Run the complete Python reference

Save this block as select_feature.py. It uses the Python standard library and was executed with Python 3.9.6. The ten assertions compare complete records, so selected-null and no-record outcomes remain distinguishable. Run without Python’s assertion-disabling optimization flag.

"""Fictional fixed in-memory history; external storage and concurrency are out of scope."""

FIELDS = ("entity", "feature", "event_tick", "available_tick", "revision", "value")


def select_feature(history, *, entity, feature, cutoff):
    def identifier(value):
        return type(value) is str and bool(value) and value == value.strip()

    def integer(value, minimum=0):
        return type(value) is int and value >= minimum

    if (type(history) is not list or not identifier(entity)
            or not identifier(feature) or not integer(cutoff)):
        raise ValueError("invalid history or query")
    seen = set()
    for row in history:
        if type(row) is not dict or set(row) != set(FIELDS):
            raise ValueError("invalid record fields")
        if not (identifier(row["entity"]) and identifier(row["feature"])
                and integer(row["event_tick"]) and integer(row["available_tick"])
                and integer(row["revision"], 1)
                and (row["value"] is None or integer(row["value"]))
                and row["available_tick"] >= row["event_tick"]):
            raise ValueError("invalid record values")
        identity = (row["entity"], row["feature"], row["event_tick"], row["revision"])
        if identity in seen:
            raise ValueError("duplicate version identity")
        seen.add(identity)
    eligible = (row for row in history
                if row["entity"] == entity and row["feature"] == feature
                and row["event_tick"] <= cutoff and row["available_tick"] <= cutoff)
    best = max(eligible, key=lambda row: (row["event_tick"], row["revision"]),
               default=None)
    return None if best is None else best.copy()


HISTORY = [dict(zip(FIELDS, row)) for row in [
    ("queue-a", "backlog", 10, 11, 1, 4),
    ("queue-a", "backlog", 10, 18, 2, 9),
    ("queue-a", "backlog", 14, 16, 1, 6),
    ("queue-a", "backlog", 14, 16, 2, 7),
    ("queue-a", "workers", 9, 9, 1, 0),
    ("queue-b", "backlog", 12, 12, 1, 100),
    ("queue-a", "workers", 13, 13, 1, None),
]]

CASES = [  # Last column: zero-based record index; None means no record.
    ("queue-a", "backlog", 12, 0),
    ("queue-a", "backlog", 15, 0),
    ("queue-a", "backlog", 16, 3),
    ("queue-a", "backlog", 18, 3),
    ("queue-a", "workers", 12, 4),
    ("queue-a", "workers", 13, 6),
    ("queue-a", "workers", 8, None),
    ("queue-z", "backlog", 18, None),
    ("queue-a", "temperature", 18, None),
    ("queue-b", "backlog", 12, 5),
]


if __name__ == "__main__":
    event_only = max(
        (row for row in HISTORY if row["entity"] == "queue-a"
         and row["feature"] == "backlog" and row["event_tick"] <= 12),
        key=lambda row: (row["event_tick"], row["revision"]))
    selected = select_feature(HISTORY, entity="queue-a", feature="backlog", cutoff=12)
    print("event-only at 12:", event_only["value"])
    print("availability-aware at 12:", selected["value"])
    for entity, feature, cutoff, index in CASES:
        expected = None if index is None else HISTORY[index]
        assert select_feature(HISTORY, entity=entity, feature=feature,
                              cutoff=cutoff) == expected
    print("PASS 10 specified feature-selection cases")

Run:

python3 select_feature.py

The tested output is:

event-only at 12: 9
availability-aware at 12: 4
PASS 10 specified feature-selection cases

Python’s max reference describes the key function and empty-iterable default. Tuple comparisons compare successive elements, so event time wins before revision. Rejecting duplicate identities prevents iteration order from resolving otherwise ambiguous equal keys within the requested entity and feature.

Trace all ten cutoff cases

The table restates the executable cases. A selected null belongs to R7; the three no-record cases return outer None.

Entity Feature Cutoff Selected record Reason
queue-a backlog 12 R1, value 4 R2 is unavailable
queue-a backlog 15 R1, value 4 R3 and R4 are measured but unavailable
queue-a backlog 16 R4, value 7 Inclusive boundary; revision 2 wins
queue-a backlog 18 R4, value 7 R2’s later arrival belongs to an older event
queue-a workers 12 R5, value 0 Zero remains a selected value
queue-a workers 13 R7, value null Null remains a selected record
queue-a workers 8 No record Request precedes worker history
queue-z backlog 18 No record Entity is absent
queue-a temperature 18 No record Feature is absent
queue-b backlog 12 R6, value 100 Only the requested entity matches

At cutoff 16, R3 and R4 share both timestamps. Their revision numbers provide the deterministic choice. At 18, sorting by availability instead would incorrectly let R2 replace the newer event represented by R4.

Ties and missing results also deserve attention in real tooling. Feast v0.68.0’s November 10, 2026 release notes include Dask handling updates for timestamp ties and historical requests without eligible features. That narrow release fact reinforces the need to test these outcomes; it neither defines this fixture’s ranking nor reports a current product defect.

To extend your checks, try an empty list, reverse row order and insert a duplicate identity. Add a malformed unrelated row to confirm validation still rejects it. Mutate a returned dictionary and verify the original stays unchanged. These are useful additional exercises, separate from the ten printed cases.

Connect the contract to a real ML design discussion

A timestamp column needs a documented meaning. Feast’s point-in-time concepts describe created timestamps for deduplication and an optional created-time cutoff. That cutoff represents availability only if the field actually records usable availability on the intended path; supported stores and null-created timestamps have documented caveats.

AWS’s offline-store format distinguishes API invocation and write timestamps, warning that write_time does not necessarily mean queryability. Renaming such a field available_tick would not establish this exercise’s assumption.

Before extending the design, ask:

  • Where is first usable availability observed, and what happens during serving propagation delays?
  • Are original versions retained when corrections arrive?
  • What should the model do with a selected null or no record?
  • Does the feature need a freshness window, and what evidence compares historical inputs with actual serving inputs?

No time-to-live (TTL), or age limit, is applied here. Databricks documents lookback windows and retaining stored null values; Feast documents TTL relative to each request’s timestamp. Freshness and null policy therefore need deliberate treatment beyond this fixture.

The helper selects one feature. It provides no atomic multi-feature read, concurrent-storage behavior, online/offline parity or guarantee against leakage in upstream computations, labels or preprocessing. Its result depends on truthful availability metadata. Use the machine learning role catalog to check the target role’s requirements; LLM application preparation has a different worked example in the AI engineer interview questions guide.

Prepin is an AI hiring platform with a free AI career team for candidates. For role-focused interview rehearsal, Practice this interview.

Frequently asked questions

What is a point-in-time join in ML system design?

It associates a historical request with feature values eligible at that request’s time. State the timestamp meanings and version policy before writing the lookup; this exercise additionally replays recorded availability on an assumed serving-input path.

Should I sort by the most recent arrival?

Only if that matches your stated feature contract. Here, arrival controls eligibility, while event and revision control preference: R2 arrives at 18 but cannot replace event 14’s R4.

Is a selected null the same as missing history?

No. R7 is an eligible record with a null payload; outer None means no eligible record exists. Returning the full record preserves that distinction for a later model-input policy.

Does passing these checks prevent all data leakage?

No. The checks cover the supplied selection contract, while upstream computations could still contain future information. Examine preprocessing, labels, metadata provenance and serving behavior separately.

Sources

Prepared with AI assistance. Sources checked November 26, 2026. The fictional fixture and its expected results are an original practice exercise.

Oleh Savchuk, founder of Prepin

Oleh Savchuk

Founder, Prepin

Oleh Savchuk is the founder of Prepin, an AI hiring platform that gives candidates a free AI career team and gives hiring teams AI recruiting agents. He is a software engineer in Philadelphia and writes about technical hiring, AI in recruiting and interview preparation.

Practice the interview out loud

Run a realistic AI mock interview for your target role and get feedback on every answer.

Start a mock interview →

Screen engineers before the first call

Send candidates one link. Prepin runs the technical voice interview and live coding, then gives you a scored report.

See how screening works →