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
Next Next commit
add aggregation in OnDemandFeatureView
Signed-off-by: hao-xu5 <hxu44@apple.com>
  • Loading branch information
hao-xu5 committed Sep 24, 2025
commit e707552d51135b84b5fbdc978dd4b0a0dcd1cff6
6 changes: 6 additions & 0 deletions sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pyarrow
from typeguard import typechecked

from feast.aggregation import Aggregation
from feast.base_feature_view import BaseFeatureView
from feast.data_source import RequestSource
from feast.entity import Entity
Expand Down Expand Up @@ -76,6 +77,7 @@ class OnDemandFeatureView(BaseFeatureView):
singleton: bool
udf: Optional[FunctionType]
udf_string: Optional[str]
aggregations: List[Aggregation]

def __init__( # noqa: C901
self,
Expand All @@ -93,6 +95,7 @@ def __init__( # noqa: C901
owner: str = "",
write_to_online_store: bool = False,
singleton: bool = False,
aggregations: Optional[List[Aggregation]] = None,
):
"""
Creates an OnDemandFeatureView object.
Expand All @@ -118,6 +121,7 @@ def __init__( # noqa: C901
the online store for faster retrieval.
singleton (optional): A boolean that indicates whether the transformation is executed on a singleton
(only applicable when mode="python").
aggregations (optional): List of aggregations to apply before transformation.
"""
super().__init__(
name=name,
Expand Down Expand Up @@ -187,6 +191,7 @@ def __init__( # noqa: C901
self.singleton = singleton
if self.singleton and self.mode != "python":
raise ValueError("Singleton is only supported for Python mode.")
self.aggregations = aggregations or []

def get_feature_transformation(self) -> Transformation:
if not self.udf:
Expand Down Expand Up @@ -251,6 +256,7 @@ def __eq__(self, other):
or self.write_to_online_store != other.write_to_online_store
or sorted(self.entity_columns) != sorted(other.entity_columns)
or self.singleton != other.singleton
or self.aggregations != other.aggregations
):
return False

Expand Down
Loading