Sub topic 11
Materializing features into the online store
This chapter assumes you have a Feast repository with an entity, a file source and a feature view, and that you have run feast apply. It also assumes you know the difference between offline retrieval with get_historical_features and online retrieval with get_online_features. Here you will learn how feature values move from the offline source into the online store, and what can go wrong on the way.
What materialization does
The online store starts empty after feast apply. Applying only registers definitions in the registry. It copies no data. Calling get_online_features at this point returns None for every feature value.
Materialization fills the online store. For each feature view in scope, Feast does the following:
- Reads rows from the offline source whose event timestamps fall inside a time window.
- Keeps only the latest row per entity key. "Latest" means the greatest
event_timestamp. If you configured acreated_timestamp_column, Feast uses it to break ties between rows with the same event timestamp. - Writes those rows to the online store, keyed by entity key and feature view.
- Records the window's end time in the registry.
The online store therefore holds one current row per entity per feature view. It does not hold history. Writing a newer row for the same entity overwrites the older one.
Two commands: materialize and materialize-incremental
Feast offers two ways to run materialization.
feast materialize START END loads an explicit window. Use it for backfills, for repairing a gap, or for testing.
feast materialize 2025-01-01T00:00:00 2025-01-02T00:00:00feast materialize-incremental END loads from the last recorded end time up to END. Feast stores that last end time per feature view in the registry. This is the command to schedule.
feast materialize-incremental $(date -u +"%Y-%m-%dT%H:%M:%S")Both commands accept --views (or -v) to limit the run to named feature views. Use it when one view's source is late and you do not want to block the others.
Pass timestamps in UTC. Feast treats timestamps without a timezone as UTC. A local-time string on a machine not set to UTC shifts your window by hours without any error.
The same operation from Python
Scheduler jobs and notebooks often call the SDK directly. The two methods match the CLI commands.
from datetime import datetime, timedelta, timezone
from feast import FeatureStore
store = FeatureStore(repo_path=".")
end = datetime.now(timezone.utc)
# Explicit window: backfill the last 7 days.
store.materialize(start_date=end - timedelta(days=7), end_date=end)
# Incremental: continue from the last recorded end time.
store.materialize_incremental(end_date=end)
# Check the result.
result = store.get_online_features(
features=["driver_hourly_stats:conv_rate", "driver_hourly_stats:acc_rate"],
entity_rows=[{"driver_id": 1001}],
).to_dict()
print(result)If the printed values are None, either no source row for driver 1001 fell inside the window, or the feature view has online=False.
The first incremental run and the TTL
The first materialize-incremental for a feature view has no recorded end time. Feast needs a start, and it derives one from the TTL. With ttl=timedelta(days=1), the first run loads only the last day of data, ending at END.
This catches many teams out. Suppose your Parquet file holds three months of history and you run only materialize-incremental. The online store gets just the final day. Entities whose latest row is older than that get no value. If you need the older rows, run an explicit feast materialize backfill first.
If a feature view has no TTL, the default start depends on your Feast version, so read the behavior in your release's documentation before relying on it.
What counts as in the window
Materialization selects rows by the source's timestamp_field, which is event_timestamp in the earlier examples. It does not select by the time the pipeline ran or by created. Two consequences follow:
- Rows that arrive late are missed. If a row with event time 10:00 lands in the source at 11:30, and your incremental run already advanced past 11:00, a later incremental run does not go back for it. Re-run an explicit window to pick it up.
- Rows with future event times are skipped until the window's end passes them.
Because only the latest row per entity is kept, a late row older than what is already online is harmless. It loses the comparison and does not overwrite newer data.
Where freshness is decided
Online values are only as fresh as your last materialization. If the job runs hourly, a driver's feature can be up to an hour behind the source, plus the delay before the source itself updates.
TTL also applies at read time. When you call get_online_features, Feast compares each stored row's event timestamp with the current time. If the row is older than the TTL, the value returns as None (null). The TTL here acts as a staleness limit, not a deletion schedule.
This shows up as a pattern: if materialization stalls for longer than the TTL, every feature starts returning nulls, even though the online store still holds data. A stalled job is a production incident, so monitor it.
| Symptom | Likely cause | Fix |
|---|---|---|
| All values `None` after `feast apply` | Nothing materialized yet | Run materialization |
| Values `None` for some entities only | Their latest row is older than the TTL, or outside the window | Backfill with `feast materialize` |
| Values `None` for all entities after days of working | Job stalled and rows exceeded the TTL | Fix the schedule, then materialize |
| Values are stale but not `None` | Job runs less often than needed | Increase frequency or consider push ingestion |
| Command succeeds, no values written | Window has no rows, or `online=False` | Check source timestamps and the feature view |
Scheduling
Materialization has no built-in scheduler. You run it from something that does: cron, Airflow, a Kubernetes CronJob, or a similar tool. A cron entry for an hourly job looks like this:
0 * * * * cd /opt/feature_repo && feast materialize-incremental $(date -u +"\%Y-\%m-\%dT\%H:\%M:\%S")Cron treats % specially, so each one is escaped with a backslash. The command is safe to re-run. Writing the same latest row twice gives the same online state. This is idempotence, and it lets a scheduler retry a failed run without cleanup.
Do not run two materialization jobs against the same feature view at the same time. Both read and update the recorded end time in the registry, and overlapping runs can leave it inconsistent.
Cost and scale
Materialization reads from the offline store, so its cost grows with the window size and the source's partitioning. On a warehouse, a query that scans the whole table each hour is expensive. Partition the source by time. Keep the incremental window small, since only the newest rows matter. For large backfills, split the range into chunks (for example one day per call) so a failure loses little work.
Summary of the model
- Materialization copies the latest row per entity from a time window of the offline source into the online store.
materializetakes an explicit window.materialize-incrementalcontinues from a stored end time.- The first incremental run starts at
END - TTL, so a long history needs an explicit backfill. - Late data is not picked up by incremental runs.
- If materialization lags past the TTL, online reads return nulls.
Exercise
Your offline Parquet file has 90 days of driver history. The feature view has ttl=timedelta(days=1). You run feast apply, then feast materialize-incremental once, and then get_online_features for a driver whose last row is 5 days old. What do you get, and what command fixes it?
Show answer
You get None for that driver's features. The first incremental run loaded only the last day (end minus TTL), so the 5-day-old row was never written. Even if it had been written, the TTL check at read time would also treat a row that old as stale. Run an explicit backfill such as feast materialize START END over the period you need, and make sure the data is recent enough that the TTL does not null it out.
Exercise
A row with event_timestamp 10:00 arrives in the source at 11:30. Your hourly incremental job already ran at 11:00 and recorded 11:00 as its end time. Will the 12:00 incremental run write this row? How do you load it?
Show answer
No. The 12:00 run starts at 11:00, so a row with event time 10:00 is outside its window. Run feast materialize 2025-01-01T10:00:00 2025-01-01T11:00:00 (with your actual date) to cover the missed window.