Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-keyed feature in anchor (direct purview) #676

Merged
merged 2 commits into from
Sep 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions feathr_project/feathr/registry/_feature_registry_purview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,11 +1396,21 @@ def _get_features_by_guid_or_entities(self, guid_list, entity_list) -> List[Feat
raise RuntimeError("Number of `feature_entities` is less than provided GUID list for search. The project might be broken.")

feature_list=[]
key_list = []
for feature_entity in feature_entities:
first_key = feature_entity["attributes"]["key"][0]
key_list = [TypedKey(key_column=first_key["keyColumn"], key_column_type=first_key["keyColumnType"], full_name=first_key["fullName"], description=first_key["description"], key_column_alias=first_key["keyColumnAlias"])]


'''
The assumption here is , a feture could have multiple keys, and features inside an anchor should share the same set of keys.
So we will take any one of the feature, extract its keys , dedup them by full name, and use them to generate the key list.
'''
first_feature_keys = feature_entities[0]["attributes"]["key"]
deduped_keys = dict()
for key in first_feature_keys:
if key['fullName'] not in deduped_keys:
deduped_keys.setdefault(key['fullName'],key)
key_list = [
TypedKey(key_column=key["keyColumn"], key_column_type=key["keyColumnType"], full_name=key["fullName"], description=key["description"], key_column_alias=key["keyColumnAlias"])\
for key in list(deduped_keys.values())
]
for feature_entity in feature_entities:
# after get keys, put them in features
feature_list.append(Feature(name=feature_entity["attributes"]["name"],
feature_type=self._get_feature_type_from_hocon(feature_entity["attributes"]["type"]), # stored as a hocon string, can be parsed using pyhocon
Expand Down