Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 10 additions & 1 deletion sdk/python/feast/infra/offline_stores/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,16 @@ def get_table_column_names_and_types_from_data_source(
return zip(table.column("name").to_pylist(), table.column("type").to_pylist())


def _create_retrieval_metadata(feature_refs: List[str], entity_df: pd.DataFrame):
def _create_retrieval_metadata(
feature_refs: List[str], entity_df: Optional[pd.DataFrame] = None
):
if entity_df is None:
return RetrievalMetadata(
features=feature_refs,
keys=[], # No entity keys when no entity_df provided
min_event_timestamp=None,
max_event_timestamp=None,
)
entity_schema = _get_entity_schema(
entity_df=entity_df,
)
Expand Down
15 changes: 15 additions & 0 deletions sdk/python/feast/offline_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Any, Dict, List, Optional, cast

import click
import pandas as pd
import pyarrow as pa
import pyarrow.flight as fl
from google.protobuf.json_format import Parse
Expand Down Expand Up @@ -431,6 +432,20 @@ def get_historical_features(self, command: dict, key: Optional[str] = None):
# Extract parameters from the internal flights dictionary
entity_df_value = self.flights[key]
entity_df = pa.Table.to_pandas(entity_df_value)
# Check if this is a mock/empty table (contains only 'key' column)
if len(entity_df.columns) == 1 and "key" in entity_df.columns:
entity_df = None

# If no entity_df provided, create minimal one with timestamps
if entity_df is None and "start_date" in command and "end_date" in command:
# Create minimal entity_df with event_timestamp when using start_date/end_date mode
start_date = utils.make_tzaware(
datetime.fromisoformat(command["start_date"])
)
end_date = utils.make_tzaware(datetime.fromisoformat(command["end_date"]))
entity_df = pd.DataFrame(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should not need to create dummy entity_df at all. We should handle empty(entity_df=None) entity_df for and in offline_store.get_historical_features which we are returning in this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right, its not needed to create mock dataframe with timestamps, just had to make sure that empty_df is being passed.

{"event_timestamp": pd.to_datetime([start_date, end_date])}
)

feature_view_names = command["feature_view_names"]
name_aliases = command["name_aliases"]
Expand Down
Loading