Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
davitbzh committed Dec 5, 2024
1 parent 7fe58eb commit 9b168fb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
38 changes: 14 additions & 24 deletions python/hsfs/feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,36 +320,26 @@ def select_all(
# Returns
`Query`. A query object with all features of the feature group.
"""
if include_event_time and include_primary_key and include_foreign_key and include_partition_key:
removed_keys = []

if not include_event_time:
removed_keys += [self.event_time]
if not include_primary_key:
removed_keys += self.primary_key
if not include_foreign_key:
removed_keys += self.foreign_key
if not include_partition_key:
removed_keys += self.partition_key

if removed_keys:
return self.select_except(removed_keys)
else:
return query.Query(
left_feature_group=self,
left_features=self._features,
feature_store_name=self._feature_store_name,
feature_store_id=self._feature_store_id,
)
elif include_event_time:
return self.select_except(
self.primary_key + self.foreign_key + self.partition_key
)
elif include_primary_key:
return self.select_except(
self.foreign_key + self.partition_key + [self.event_time]
)
elif include_foreign_key:
return self.select_except(
self.primary_key + self.partition_key + [self.event_time]
)
elif include_partition_key:
return self.select_except(
self.primary_key + self.foreign_key + [self.event_time]
)
else:
return self.select_except(
self.primary_key
+ self.partition_key
+ self.foreign_key
+ [self.event_time]
)

def select_features(
self,
Expand Down
6 changes: 6 additions & 0 deletions python/hsfs/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ def plus_two(value):
feature group. This primary key can be a composite key of multiple
features and will be used as joining key, if not specified otherwise.
Defaults to empty list `[]`, and the feature group won't have any primary key.
foreign_key: A list of feature names to be used as foreign key for the feature group.
Foreign key is referencing the primary key of another feature group and can be used as joining key.
Defaults to empty list `[]`, and the feature group won't have any foreign key.
embedding_index: [`EmbeddingIndex`](./embedding_index_api.md). If an embedding index is provided,
vector database is used as online feature store. This enables similarity search by
using [`find_neighbors`](./feature_group_api.md#find_neighbors).
Expand Down Expand Up @@ -1238,6 +1241,9 @@ def get_or_create_spine_group(
spine group. This primary key can be a composite key of multiple
features and will be used as joining key, if not specified otherwise.
Defaults to empty list `[]`, and the spine group won't have any primary key.
foreign_key: A list of feature names to be used as foreign key for the feature group.
Foreign key is referencing the primary key of another feature group and can be used as joining key.
Defaults to empty list `[]`, and the feature group won't have any foreign key.
event_time: Optionally, provide the name of the feature containing the event
time for the features in this spine group. If event_time is set
the spine group can be used for point-in-time joins. Defaults to `None`.
Expand Down
14 changes: 10 additions & 4 deletions python/tests/test_feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,20 @@ def test_select_all(self):
def test_select_all_exclude_pk(self):
query = test_feature_group.select_all(include_primary_key=False)
features = query.features
assert len(features) == 3
assert set([f.name for f in features]) == {"ts", "f1", "f2"}
assert len(features) == 4
assert set([f.name for f in features]) == {"ts", "fk", "f1", "f2"}

def test_select_all_exclude_fk(self):
query = test_feature_group.select_all(include_foreign_key=False)
features = query.features
assert len(features) == 4
assert set([f.name for f in features]) == {"f1", "f2", "pk", "ts"}

def test_select_all_exclude_ts(self):
query = test_feature_group.select_all(include_event_time=False)
features = query.features
assert len(features) == 3
assert set([f.name for f in features]) == {"pk", "f1", "f2"}
assert len(features) == 4
assert set([f.name for f in features]) == {"pk", "fk", "f1", "f2"}

def test_select_all_exclude_pk_ts(self):
query = test_feature_group.select_all(
Expand Down

0 comments on commit 9b168fb

Please sign in to comment.