Skip to content

Commit 27e7ae8

Browse files
authored
chore: Add a join_keys field in the Entity API (feast-dev#2526)
* chore: Add a join_keys field in the Entity API Signed-off-by: Achal Shah <achals@gmail.com> * docs Signed-off-by: Achal Shah <achals@gmail.com>
1 parent 673d00c commit 27e7ae8

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

sdk/python/feast/entity.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
import warnings
1515
from datetime import datetime
16-
from typing import Dict, Optional
16+
from typing import Dict, List, Optional
1717

1818
from google.protobuf.json_format import MessageToJson
1919

@@ -40,6 +40,9 @@ class Entity:
4040
owner: The owner of the entity, typically the email of the primary maintainer.
4141
created_timestamp: The time when the entity was created.
4242
last_updated_timestamp: The time when the entity was last updated.
43+
join_keys: A list of property that uniquely identifies different entities within the
44+
collection. This is meant to replace the `join_key` parameter, but currently only
45+
supports a list of size one.
4346
"""
4447

4548
name: str
@@ -50,6 +53,7 @@ class Entity:
5053
owner: str
5154
created_timestamp: Optional[datetime]
5255
last_updated_timestamp: Optional[datetime]
56+
join_keys: List[str]
5357

5458
@log_exceptions
5559
def __init__(
@@ -61,6 +65,7 @@ def __init__(
6165
join_key: Optional[str] = None,
6266
tags: Optional[Dict[str, str]] = None,
6367
owner: str = "",
68+
join_keys: Optional[List[str]] = None,
6469
):
6570
"""Creates an Entity object."""
6671
if len(args) == 1:
@@ -82,7 +87,17 @@ def __init__(
8287
raise ValueError("Name needs to be specified")
8388

8489
self.value_type = value_type
85-
self.join_key = join_key if join_key else self.name
90+
91+
self.join_keys = join_keys or []
92+
if join_keys and len(join_keys) > 1:
93+
raise ValueError(
94+
"An entity may only have single join key. "
95+
"Multiple join keys will be supported in the future."
96+
)
97+
if join_keys and len(join_keys) == 1:
98+
self.join_key = join_keys[0]
99+
else:
100+
self.join_key = join_key if join_key else self.name
86101
self.description = description
87102
self.tags = tags if tags is not None else {}
88103
self.owner = owner

0 commit comments

Comments
 (0)