Session events pushed into a Feast PushSource with `store.push()` serve correctly online, yet `get_historical_features` never returns them for training - what causes this, and what do you change?
answer
- push has a destination argument
- the default is online only
- historical reads the batch source
- ONLINE_AND_OFFLINE needs a batch_source
- columns must match the batch table
basics
~20 sstore.push() and the feature server's /push default to PushMode.ONLINE, so pushed rows reach only the online store. Historical retrieval reads the view's batch source, which never received them; push with PushMode.ONLINE_AND_OFFLINE or land the same events in that table.
solid answer
~40 sA `PushSource` lets a stream job write rows straight into Feast, and every feature view whose source is that push source receives them. `FeatureStore.push(push_source_name, df, to=...)` defaults `to` to `PushMode.ONLINE`, and the feature server's `/push` body defaults `"to"` to `"online"`, so the rows go only to the online store. `get_historical_features` reads the feature view's batch source, the push source's `batch_source`, so the training join never sees those events. Either push with `to=PushMode.ONLINE_AND_OFFLINE`, which also writes the rows into the batch source and fails if the view has none or if the columns differ, or have the stream job write the same events to that warehouse table itself. Feast's push docs make that second responsibility explicit.
code
python · 13 linesfrom datetime import datetime, timezone
import pandas as pd
from feast import FeatureStore
from feast.data_source import PushMode
store = FeatureStore(repo_path=".")
events = pd.DataFrame({
"player_id": [1001],
"event_timestamp": [datetime.now(timezone.utc)],
"sessions_today": [4],
})
# Omitting `to` would mean PushMode.ONLINE: history never sees the row
store.push("player_session_push", events, to=PushMode.ONLINE_AND_OFFLINE)go deeper
Recall that a PushSource lets a writer send rows straight to Feast, and that push takes a destination argument that defaults to online.
Explain the three PushMode values, how a feature view uses the push source's batch_source, and what the /push request body carries.
Trace a training set missing streamed values to the push default, and choose between pushing to both stores and writing history in the stream job.
Decide which component owns the historical record for streamed features, and make that ownership explicit for every team that pushes.
## What a PushSource is Most Feast feature views read a **batch source**, a warehouse table or file, and reach the online store through materialization. A **`PushSource`** is a data source for values that arrive from outside on their own schedule, such as a session-event stream that must be servable within seconds: - you declare `PushSource(name=..., batch_source=...)`, where the optional `batch_source` is the table holding the same rows as history; - a `FeatureView` whose `source` is the push source treats it as its stream source and uses its `batch_source` for historical retrieval and for materialization; - a writer calls `store.push("player_session_push", df)` from the SDK, or posts to the feature server's `/push` endpoint (port 6566 by default under `feast serve`), and Feast writes the rows into every feature view fed by that push source. The pushed dataframe must include the entity key and the event timestamp column alongside the features. Feast also has a `StreamFeatureView` class for stream sources with an attached transformation, which its docs label [Alpha]; a plain `FeatureView` over a push source is enough for this scenario. ## The default destination The `to` argument chooses where pushed rows go: | `to` (SDK) | `"to"` (`/push` body) | Online store | Offline batch source | |---|---|---|---| | `PushMode.ONLINE` (default) | `"online"` (default) | written | not written | | `PushMode.OFFLINE` | `"offline"` | not written | written | | `PushMode.ONLINE_AND_OFFLINE` | `"online_and_offline"` | written | written | With the default, the game backend sees fresh session counts through `get_online_features`, while `get_historical_features` joins against a batch source that never got those rows. The training set is then built from whatever else fills the batch table, often nothing for recent days, so recent impressions get nulls or older values. No error is raised on either side. ## The two ways to close the gap 1. **Push to both stores.** Call `store.push(..., to=PushMode.ONLINE_AND_OFFLINE)` or send `"to": "online_and_offline"`. Feast writes online, then persists the rows into the view's batch source through the offline store. Two conditions apply: the feature view must have a `batch_source` (otherwise Feast raises `Feature view '<name>' has no batch_source.`), and the dataframe's columns must match the batch source's columns, which Feast checks and can reorder. 2. **Write the history yourself.** Keep pushing online only and have the stream job also append the same events to the warehouse table named as `batch_source`. Feast's push-source docs state that when a `batch_source` is used, users are responsible for making sure data also reaches it. On the feature server, offline writes from `/push` can be buffered with `offline_push_batching_enabled` and its size and interval settings in the `feature_server` block of `feature_store.yaml`; with `"online_and_offline"` the online write stays immediate and only the offline half is batched, so history lags the online store by up to the flush interval. ## Interplay with materialization The same feature view can also be materialized from its batch source. Two details keep the stores consistent: - the Redis store's default write path reads stored timestamps first and does not overwrite a newer value with an older one, so a nightly materialize does not roll back a fresher pushed value; `skip_dedup: true` removes that check and should be kept for controlled bulk loads; - if pushes go online only and nothing writes history, materialization from the batch source has nothing recent to load, which matters again whenever the online store is rebuilt. Whether online and training values match in general is the training-serving skew material's subject; here the cause is a single argument default. ## Diagnosing it - Grep the writer for `push(` and `/push` calls and read the `to` value; absent means online only. - Query the batch source for the newest event timestamp per key and compare with the online value's timestamp. - Confirm the feature view's batch source is the table the training job expects. - With metrics enabled in the `feature_server` block, read `feast_push_request_total`, which counts pushes by push source and mode; a mode label that never shows an offline write settles the question quickly. - After switching to `online_and_offline`, history fills only from that moment. Earlier pushes left no offline trace, so the gap has to be rebuilt from wherever the raw events were archived, written into the batch table with the same columns.
- What happens if you push with `PushMode.ONLINE_AND_OFFLINE` to a view whose PushSource has no `batch_source`?The online write goes through, then the offline write fails: Feast raises a `ValueError` saying the feature view has no batch_source. Declaring the push source with a `batch_source` table is what gives the view a history to train on.
- Can a later nightly materialize overwrite a fresher value that was pushed online?Not with the Redis store's default write path: it reads the stored event timestamp first and skips older rows. With `skip_dedup: true` that check is gone, and an older materialized row can overwrite a newer pushed one.
- store.push writes to both stores by default
- get_historical_features reads values from the online store
- a PushSource needs no batch_source to train on pushed data
- pushing requires a StreamFeatureView rather than a FeatureView
- a nightly materialize always overwrites pushed online values