You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 564e965
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/reference/beta-on-demand-feature-view.md
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,10 +35,40 @@ When defining an ODFV, you can specify the transformation mode using the `mode`
35
35
36
36
### Singleton Transformations in Native Python Mode
37
37
38
-
Native Python mode supports transformations on singleton dictionaries by setting `singleton=True`. This allows you to
39
-
write transformation functions that operate on a single row at a time, making the code more intuitive and aligning with
38
+
Native Python mode supports transformations on singleton dictionaries by setting `singleton=True`. This allows you to
39
+
write transformation functions that operate on a single row at a time, making the code more intuitive and aligning with
40
40
how data scientists typically think about data transformations.
41
41
42
+
## Aggregations
43
+
44
+
On Demand Feature Views support aggregations that compute aggregate statistics over groups of rows. When using aggregations, data is grouped by entity columns (e.g., `driver_id`) and aggregated before being passed to the transformation function.
45
+
46
+
**Important**: Aggregations and transformations are mutually exclusive. When aggregations are specified, they replace the transformation function.
47
+
48
+
### Usage
49
+
50
+
```python
51
+
from feast import Aggregation
52
+
from datetime import timedelta
53
+
54
+
@on_demand_feature_view(
55
+
sources=[driver_hourly_stats_view],
56
+
schema=[
57
+
Field(name="total_trips", dtype=Int64),
58
+
Field(name="avg_rating", dtype=Float64),
59
+
],
60
+
aggregations=[
61
+
Aggregation(column="trips", function="sum"),
62
+
Aggregation(column="rating", function="mean"),
63
+
],
64
+
)
65
+
defdriver_aggregated_stats(inputs):
66
+
# No transformation function needed when using aggregations
67
+
pass
68
+
```
69
+
70
+
Aggregated columns are automatically named using the pattern `{function}_{column}` (e.g., `sum_trips`, `mean_rating`).
71
+
42
72
## Example
43
73
See [https://github.com/feast-dev/on-demand-feature-views-demo](https://github.com/feast-dev/on-demand-feature-views-demo) for an example on how to use on demand feature views.
0 commit comments