Skip to content

Commit 38cf9cb

Browse files
authored
Add public docs for entity aliasing (#1951)
* Add example in docs for entity aliasing Signed-off-by: Cody Lin <codyl@twitter.com> * Improve the paragraph organization and make it clearer Signed-off-by: Cody Lin <codyl@twitter.com>
1 parent 0dfc8bd commit 38cf9cb

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

docs/getting-started/concepts/feature-view.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,54 @@ global_stats_fv = FeatureView(
5353
{% endtab %}
5454
{% endtabs %}
5555

56+
## Entity aliasing
57+
58+
"Entity aliases" can be specified to join `entity_dataframe` columns that do not match the column names in the source table of a FeatureView.
59+
60+
This could be used if a user has no control over these column names or if there are multiple entities are a subclass of a more general entity. For example, "spammer" and "reporter" could be aliases of a "user" entity, and "origin" and "destination" could be aliases of a "location" entity as shown below.
61+
62+
It is suggested that you dynamically specify the new FeatureView name using `.with_name` and `join_key_map` override using `.with_join_key_map` instead of needing to register each new copy.
63+
64+
{% tabs %}
65+
{% tab title="location_stats_feature_view.py" %}
66+
```python
67+
location = Entity(name="location", join_key="location_id", value_type=ValueType.INT64)
68+
69+
location_stats_fv= FeatureView(
70+
name="location_stats",
71+
entities=["location"],
72+
features=[
73+
Feature(name="temperature", dtype=ValueType.INT32)
74+
],
75+
batch_source=BigQuerySource(
76+
table_ref="feast-oss.demo_data.location_stats"
77+
),
78+
)
79+
```
80+
{% endtab %}
81+
{% tab title="temperatures_feature_service.py" %}
82+
```python
83+
from location_stats_feature_view import location_stats_fv
84+
85+
temperatures_fs = FeatureService(
86+
name="temperatures",
87+
features=[
88+
location_stats_feature_view
89+
.with_name("origin_stats")
90+
.with_join_key_map(
91+
{"location_id": "origin_id"}
92+
),
93+
location_stats_feature_view
94+
.with_name("destination_stats")
95+
.with_join_key_map(
96+
{"location_id": "destination_id"}
97+
),
98+
],
99+
)
100+
```
101+
{% endtab %}
102+
{% endtabs %}
103+
56104
## Feature
57105

58106
A feature is an individual measurable property. It is typically a property observed on a specific entity, but does not have to be associated with an entity. For example, a feature of a `customer` entity could be the number of transactions they have made on an average month, while a feature that is not observed on a specific entity could be the total number of posts made by all users in the last month.

0 commit comments

Comments
 (0)