Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removal of unnecessary checks & made both dates timezone aware
Signed-off-by: Aniket Paluskar <apaluska@redhat.com>
  • Loading branch information
aniketpalu committed Nov 23, 2025
commit b28ea1911e1379ce9dc97e241961bf53ea428bbc
15 changes: 7 additions & 8 deletions sdk/python/feast/infra/offline_stores/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from feast.on_demand_feature_view import OnDemandFeatureView
from feast.repo_config import FeastConfigBaseModel, RepoConfig
from feast.saved_dataset import SavedDatasetStorage
from feast.utils import _get_requested_feature_views_to_features_dict
from feast.utils import _get_requested_feature_views_to_features_dict, make_tzaware

# DaskRetrievalJob will cast string objects to string[pyarrow] from dask version 2023.7.1
# This is not the desired behavior for our use case, so we set the convert-string option to False
Expand Down Expand Up @@ -152,7 +152,9 @@ def get_historical_features(

if non_entity_mode:
# Default end_date to current time (UTC) to keep behavior predictable without extra parameters.
end_date = end_date or datetime.now(timezone.utc)
end_date = (
make_tzaware(end_date) if end_date else datetime.now(timezone.utc)
)

# When start_date is not provided, choose a conservative lower bound using max TTL, otherwise fall back.
if start_date is None:
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.

If start_date is given you have to make it tzaware ?

Expand All @@ -167,6 +169,7 @@ def get_historical_features(
else:
# Keep default window bounded to avoid unbounded scans by default.
start_date = end_date - timedelta(days=30)
start_date = make_tzaware(start_date)

Comment on lines +159 to +173
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The start_date parameter is not enforced in the actual data filtering - only the end_date is used (along with TTL). The filtering logic in _filter_ttl will use end_date - ttl as the lower bound, not the user-provided start_date. This means if a user provides start_date that is later than end_date - ttl, they may get more data than expected.

Consider adding a validation check or warning when start_date is provided but will be overridden by TTL logic, or add a TODO comment indicating that proper start_date filtering should be implemented in a follow-up.

Suggested change
# When start_date is not provided, choose a conservative lower bound using max TTL, otherwise fall back.
if start_date is None:
max_ttl_seconds = 0
for fv in feature_views:
if fv.ttl and isinstance(fv.ttl, timedelta):
max_ttl_seconds = max(
max_ttl_seconds, int(fv.ttl.total_seconds())
)
if max_ttl_seconds > 0:
start_date = end_date - timedelta(seconds=max_ttl_seconds)
else:
# Keep default window bounded to avoid unbounded scans by default.
start_date = end_date - timedelta(days=30)
# Compute TTL-based lower bound for start_date.
max_ttl_seconds = 0
for fv in feature_views:
if fv.ttl and isinstance(fv.ttl, timedelta):
max_ttl_seconds = max(
max_ttl_seconds, int(fv.ttl.total_seconds())
)
if max_ttl_seconds > 0:
ttl_lower_bound = end_date - timedelta(seconds=max_ttl_seconds)
else:
# Keep default window bounded to avoid unbounded scans by default.
ttl_lower_bound = end_date - timedelta(days=30)
# If user provided start_date, use the max of user start_date and ttl_lower_bound.
if start_date is not None:
if start_date < ttl_lower_bound:
import warnings
warnings.warn(
f"Provided start_date ({start_date}) is earlier than TTL-based lower bound ({ttl_lower_bound}). Overriding start_date to {ttl_lower_bound}."
)
start_date = max(start_date, ttl_lower_bound)
else:
start_date = ttl_lower_bound

Copilot uses AI. Check for mistakes.
# Minimal synthetic entity_df: one timestamp row; join keys are not materialized here on purpose to avoid
# accidental dependence on specific feature view schemas at this layer.
Expand All @@ -178,7 +181,7 @@ def get_historical_features(
entity_df, dd.DataFrame
):
raise ValueError(
f"Please provide an entity_df of type {type(pd.DataFrame)} or dask.dataframe instead of type {type(entity_df)}"
f"Please provide an entity_df of type pd.DataFrame or dask.dataframe.DataFrame instead of type {type(entity_df)}"
)
entity_df_event_timestamp_col = DEFAULT_ENTITY_DF_EVENT_TIMESTAMP_COL # local modifiable copy of global variable
if entity_df_event_timestamp_col not in entity_df.columns:
Expand Down Expand Up @@ -296,15 +299,11 @@ def evaluate_historical_retrieval():
full_feature_names,
)

# df_to_join = _merge(entity_df_with_features, df_to_join, join_keys)

# In non-entity mode, if the synthetic entity_df lacks join keys, cross join to build a snapshot
# of all entities as-of the requested timestamp, then rely on TTL and deduplication to select
# the appropriate latest rows per entity.
current_join_keys = join_keys
if non_entity_mode and any(
k not in entity_df_with_features.columns for k in join_keys
):
if non_entity_mode:
current_join_keys = []

df_to_join = _merge(
Expand Down