Skip to content

Commit 857876b

Browse files
chore: Remove join_keys attribute (feast-dev#3159)
Remove `join_keys` attribute Signed-off-by: Felix Wang <[email protected]> Signed-off-by: Felix Wang <[email protected]>
1 parent 5ddb83b commit 857876b

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

sdk/python/feast/entity.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class Entity:
3333
Attributes:
3434
name: The unique name of the entity.
3535
value_type: The type of the entity, such as string or float.
36-
join_keys: A list of properties that uniquely identifies different entities within the
37-
collection. This currently only supports a list of size one, but is intended to
38-
eventually support multiple join keys.
3936
join_key: A property that uniquely identifies different entities within the
4037
collection. The join_key property is typically used for joining entities
4138
with their associated features. If not specified, defaults to the name.
@@ -48,7 +45,6 @@ class Entity:
4845

4946
name: str
5047
value_type: ValueType
51-
join_keys: List[str]
5248
join_key: str
5349
description: str
5450
tags: Dict[str, str]
@@ -84,21 +80,17 @@ def __init__(
8480
self.name = name
8581
self.value_type = ValueType.UNKNOWN
8682

87-
# For now, both the `join_key` and `join_keys` attributes are set correctly,
88-
# so both are usable.
89-
# TODO(felixwang9817): Fully remove the usage of `join_key` throughout the codebase,
90-
# at which point the `join_key` attribute no longer needs to be set.
9183
if join_keys and len(join_keys) > 1:
84+
# TODO(felixwang9817): When multiple join keys are supported, add a `join_keys` attribute
85+
# and deprecate the `join_key` attribute.
9286
raise ValueError(
93-
"An entity may only have single join key. "
87+
"An entity may only have a single join key. "
9488
"Multiple join keys will be supported in the future."
9589
)
9690
elif join_keys and len(join_keys) == 1:
97-
self.join_keys = join_keys
9891
self.join_key = join_keys[0]
9992
else:
10093
self.join_key = self.name
101-
self.join_keys = [self.join_key]
10294

10395
self.description = description
10496
self.tags = tags if tags is not None else {}

sdk/python/feast/feature_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ def __init__(
155155
features: List[Field] = []
156156
self.entity_columns = []
157157

158-
join_keys = []
158+
join_keys: List[str] = []
159159
if entities:
160160
for entity in entities:
161-
join_keys += entity.join_keys
161+
join_keys.append(entity.join_key)
162162

163163
for field in self.schema:
164164
if field.name in join_keys:

sdk/python/feast/inference.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,11 @@ def update_feature_views_with_inferred_features_and_entities(
115115
config: The config for the current feature store.
116116
"""
117117
entity_name_to_entity_map = {e.name: e for e in entities}
118-
entity_name_to_join_keys_map = {e.name: e.join_keys for e in entities}
118+
entity_name_to_join_key_map = {e.name: e.join_key for e in entities}
119119

120120
for fv in fvs:
121121
join_keys = set(
122-
[
123-
join_key
124-
for entity_name in fv.entities
125-
for join_key in entity_name_to_join_keys_map[entity_name]
126-
]
122+
[entity_name_to_join_key_map[entity_name] for entity_name in fv.entities]
127123
)
128124

129125
# Fields whose names match a join key are considered to be entity columns; all
@@ -164,13 +160,7 @@ def update_feature_views_with_inferred_features_and_entities(
164160
fv.entity_columns.append(Field(name=DUMMY_ENTITY_ID, dtype=String))
165161

166162
# Run inference for entity columns if there are fewer entity fields than expected.
167-
num_expected_join_keys = sum(
168-
[
169-
len(entity_name_to_join_keys_map[entity_name])
170-
for entity_name in fv.entities
171-
]
172-
)
173-
run_inference_for_entities = len(fv.entity_columns) < num_expected_join_keys
163+
run_inference_for_entities = len(fv.entity_columns) < len(join_keys)
174164

175165
# Run inference for feature columns if there are no feature fields.
176166
run_inference_for_features = len(fv.features) == 0

0 commit comments

Comments
 (0)