Repository navigation
Description
Expected Behavior
LocalComputeEngine.get_historical_features(registry, HistoricalRetrievalTask(...)) returns one point-in-time correct row per entity_df row. The compute engine docs describe get_historical_features() as "point-in-time correct training dataset retrieval" and list LocalHistoricalRetrievalJob as supported by the local engine. FeatureStore.get_historical_features (Dask offline store) returns that for the inputs below, and the Trino and Flink builders already join entity_df on this path.
Current Behavior
For a BatchFeatureView backed by a data source, the local engine returns the latest row per join key across the whole source:
- entities that are not in
entity_dfcome back; - the
entity_dftimestamps are ignored, soLocalFilterNode's point-in-time and TTL branch never runs (it only applies when__entity_event_timestampis present); - an entity requested at two timestamps comes back once.
There are two causes:
LocalFeatureBuilderinheritsFeatureBuilder._build, which buildssource -> [transform] -> filter -> dedupand only adds a join node when there are upstreaminput_nodes.entity_dfis never joined for a source-backed view.TrinoFeatureBuilderandFlinkFeatureBuilderoverride_buildwith_should_join_entity_df()for this reason; the same gap was flagged as a blocker on the Trino PR: feat: Add Trino compute engine for batch retrieval and materialization #6898 (comment)LocalDedupNodededups on the join keys only, andLocalAggregationNodegroups by the entities only. Even with the join in place, an entity requested at two timestamps collapses to one row (and an aggregation would sum both entity rows together). The Trino dedup adds__entity_event_timestampto itsPARTITION BY, and Flink dedups onENTITY_ROW_ID.
LocalSourceReadNode reads through create_offline_store_retrieval_job, which calls pull_latest_from_table_or_query / pull_all_from_table_or_query and does not use context.entity_df, so the offline store does not cover this either.
Scope: passthrough_provider does not route FeatureStore.get_historical_features to the batch engine yet (#6359), so this affects direct engine calls only.
Steps to reproduce
from datetime import datetime, timedelta, timezone
from unittest.mock import MagicMock
import pandas as pd
from feast import BatchFeatureView, Entity, Field, FileSource, RepoConfig, ValueType
from feast.infra.common.retrieval_task import HistoricalRetrievalTask
from feast.infra.compute_engines.local.compute import LocalComputeEngine
from feast.infra.offline_stores.dask import DaskOfflineStore, DaskOfflineStoreConfig
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.types import Float32, Int64
t0 = datetime(2026, 1, 1, tzinfo=timezone.utc)
pd.DataFrame(
{
"driver_id": [1, 1, 2],
"conv_rate": [0.1, 0.9, 0.5],
"event_timestamp": [t0, t0 + timedelta(hours=2), t0],
}
).to_parquet("/tmp/driver_stats.parquet")
driver = Entity(name="driver", join_keys=["driver_id"], value_type=ValueType.INT64)
view = BatchFeatureView(
name="driver_stats",
entities=[driver],
mode="pandas",
schema=[Field(name="driver_id", dtype=Int64), Field(name="conv_rate", dtype=Float32)],
source=FileSource(path="/tmp/driver_stats.parquet", timestamp_field="event_timestamp"),
ttl=timedelta(days=1),
online=False,
offline=False,
)
config = RepoConfig(
project="repro",
registry="/tmp/registry.db",
provider="local",
online_store=SqliteOnlineStoreConfig(path="/tmp/online.db"),
offline_store=DaskOfflineStoreConfig(),
entity_key_serialization_version=3,
)
engine = LocalComputeEngine(
repo_config=config, offline_store=DaskOfflineStore(), online_store=MagicMock()
)
# driver 1 at t0+1h and t0+3h; driver 2 is not requested
entity_df = pd.DataFrame(
{"driver_id": [1, 1], "event_timestamp": [t0 + timedelta(hours=1), t0 + timedelta(hours=3)]}
)
registry = MagicMock()
registry.get_entity.return_value = driver
task = HistoricalRetrievalTask(
project="repro", entity_df=entity_df, feature_view=view,
full_feature_name=False, registry=registry,
)
print(engine.get_historical_features(registry, task).to_df())Expected: two rows for driver 1, with conv_rate 0.1 (as of t0+1h) and 0.9 (as of t0+3h). That is what FeatureStore.get_historical_features returns for the same source and entity_df.
Actual on master (a291a0f):
conv_rate event_timestamp driver_id
0 0.9 2026-01-01 02:00:00+00:00 1
1 0.5 2026-01-01 00:00:00+00:00 2
A derived view (source=driver_stats, no transformation) goes through the join path and only returns one row for driver 1 (0.9 as of t0+3h).
Specifications
- Version: master (a291a0f), feast 0.68.1.dev
- Platform: macOS 26.5 arm64, Python 3.11.15, pandas 2.3.3, pyarrow 26.0.1
- Subsystem:
sdk/python/feast/infra/compute_engines/local
Possible Solution
Keep the base FeatureBuilder as is and fix the local engine only:
- Override
_buildinLocalFeatureBuilderas the Trino and Flink builders do: after the source node (and the transformation, if any), addbuild_join_node(view, [last_node])when the task is aHistoricalRetrievalTaskwith a pandasentity_df. - In
LocalDedupNodeandLocalAggregationNode, add__entity_event_timestampto the dedup / group-by keys when that column is present. - In
LocalJoinNode, skip the trailingentity_dfjoin when the first input already carries__entity_event_timestamp, and join such inputs on the join keys plus that column. Otherwise a derived view joinsentity_dftwice and ends up with__entity_event_timestamp_x/_ycolumns.
That is about 60 lines of source plus three unit tests in test_local_compute_engine.py (source-backed view, derived view, aggregation).
Out of scope:
- Spark.
SparkFeatureBuilderinherits the same base_build, and its read node also goes throughcreate_offline_store_retrieval_job, so it may have the same gap, but I can't test Spark here. Is that path expected to joinentity_dftoo, or is it covered somewhere I missed? - Entity rows with no feature row inside the TTL are dropped by
LocalFilterNoderather than returned with nulls. That was already the case on the derived-view path.
Open PRs nearby: #5985 changes the timestamp-column guard in LocalDedupNode (same function, different change), #7004 changes how LocalJoinNode infers the entity_df timestamp column, and #7028 adds incremental methods to LocalJoinNode. None of them changes the join or dedup keys.
I'll open the PR for this myself, with the fix above and regression tests.
Activity
Zhuoxi2000 commentedon Nov 24, 2026
I'd like to take this one myself and will open the PR. I have the fix and three regression tests ready locally (a source-backed view, a derived view on top of it, and an aggregation view). I'll open it shortly unless a maintainer would prefer a different approach.