Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sdk/python/feast/infra/compute_engines/local/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def execute(self, context: ExecutionContext) -> ArrowTableValue:
if context.entity_df is not None:
entity_df = self.backend.from_arrow(pa.Table.from_pandas(context.entity_df))

entity_schema = dict(zip(entity_df.columns, entity_df.dtypes))
# Infer from the pandas dtypes: the inference does not recognise
# the datetime dtypes of other backends (e.g. Polars).
entity_schema = dict(
zip(context.entity_df.columns, context.entity_df.dtypes)
)
Comment on lines +100 to +102

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Pandas joins reject object-backed timestamps

For an unnamed-by-convention timestamp stored as object, LocalJoinNode now raises EntityTimestampInferenceException. The pandas backend already converts Python datetimes to a recognized dtype, but inference no longer uses it.

Learn more

LocalComputeEngine.get_historical_features builds a retrieval plan whose default join is created by build_join_node. The join converts the request DataFrame through Arrow, and PandasBackend.from_arrow returns a pandas DataFrame with the resulting types. Arrow can turn a pandas object column containing Python datetimes into a timestamp column. When neither timestamp name is explicit, infer_event_timestamp_from_entity_df requires exactly one recognized datetime dtype. Reading the original dtypes hides the converted timestamp from inference and aborts the join.

Example: Pass a pandas entity DataFrame with entity_id and ts, where ts contains Python datetimes parsed from 2025-11-01T09:00:00-04:00 and 2025-11-03T09:00:00-05:00. Pandas stores the mixed offsets as object, but the Arrow round trip yields a timezone-aware datetime column. The old pandas join infers ts; the new join raises an inference exception.

Recommended fix: Preserve inference from the converted DataFrame for the pandas backend and use a pandas-compatible schema for Polars. Add a regression case with a nonstandard timestamp column backed by object to cover the Arrow normalization.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

entity_ts_col = infer_entity_timestamp_column(entity_schema)

if entity_ts_col != ENTITY_TS_ALIAS:
Expand Down
31 changes: 31 additions & 0 deletions sdk/python/tests/unit/infra/compute_engines/local/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,37 @@ def test_local_join_node():
assert "__entity_event_timestamp" in result_df.columns


@pytest.mark.parametrize("backend_name", ["pandas", "polars"])
def test_local_join_node_infers_entity_timestamp_column(backend_name):
"""The entity timestamp column is found by dtype when it has another name."""
if backend_name == "polars":
pytest.importorskip("polars")
from feast.infra.compute_engines.backends.factory import BackendFactory

context = create_context(
node_outputs={"source": ArrowTableValue(pa.Table.from_pandas(sample_df))}
)
context.entity_df = pd.DataFrame({"entity_id": [1, 2], "ts": [now, now]})

join_node = LocalJoinNode(
name="join",
backend=BackendFactory.from_name(backend_name),
column_info=ColumnInfo(
join_keys=["entity_id"],
feature_cols=["value"],
ts_col="event_timestamp",
created_ts_col=None,
),
)
join_node.add_input(MagicMock())
join_node.inputs[0].name = "source"

result_df = join_node.execute(context).data.to_pandas()
assert len(result_df) == 4
assert "ts" not in result_df.columns
assert (result_df[ENTITY_TS_ALIAS] == now).all()


def test_local_dedup_node():
# Duplicate rows for each entity with different event and created timestamps
df = pd.DataFrame(
Expand Down
Loading