fix: Validate entities when running get_online_features #5031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR addresses the issue of unexpected crashes when using feature_store.get_online_features with incorrect or missing join keys.
Specifically, it introduces validation logic in the
_get_unique_entities
function to ensure that all expected join keys are present and non-empty before proceeding.If any required join keys are missing or have empty values, a KeyError is raised with a descriptive error message. Additionally, new unit tests have been added to cover various edge cases, ensuring that the function behaves as expected under different scenarios.
Changes:
sdk/python/feast/utils.py
:_get_unique_entities
.table_entity_values
into row-wise data and handle edge cases.sdk/python/tests/unit/online_store/test_online_retrieval.py
:KeyError
is raised when required join keys are missing.sdk/python/tests/unit/test_unit_feature_store.py
:test_get_unique_entities
totest_get_unique_entities_success
for clarity.Which issue(s) this PR fixes:
#3270
Misc
It's worth noting, when one key is present and one is not, the retrieval will still succeed as this is expected behavior.