fix: ODFV output projection in offline retrieval (#6099)#6140
Open
jyejare wants to merge 3 commits intofeast-dev:masterfrom
Open
fix: ODFV output projection in offline retrieval (#6099)#6140jyejare wants to merge 3 commits intofeast-dev:masterfrom
jyejare wants to merge 3 commits intofeast-dev:masterfrom
Conversation
|
|
||
| if metadata and metadata.features: | ||
| for feature_ref in metadata.features: | ||
| if ":" in feature_ref: |
Member
There was a problem hiding this comment.
this is going to be brittle after my feature view version PR lands as feature references will now support @vN syntax.
added 3 commits
March 23, 2026 20:40
This commit fixes issue feast-dev#6099 where offline retrieval (get_historical_features) was returning ALL OnDemandFeatureView output features, even when only a subset was requested, while online retrieval correctly returned only requested features. Changes: - Modified RetrievalJob.to_arrow() to filter ODFV outputs based on requested features from metadata, matching online retrieval behavior - Added test_odfv_projection to verify the fix and prevent regression Before this fix: - Online: features=['odfv:feature_a'] -> returns feature_a only ✓ - Offline: features=['odfv:feature_a'] -> returns feature_a, feature_b, feature_c ✗ After this fix: - Both online and offline return only the requested features ✓ This ensures schema consistency between training (offline) and serving (online) pipelines, preventing downstream issues in ML workflows. Fixes feast-dev#6099
- Fix empty list edge case: Use explicit dict key check instead of 'or' operator to avoid treating empty sets as falsy - Use sets instead of lists for requested features to prevent duplicates and improve lookup performance (O(1) instead of O(n))
Some RetrievalJob implementations don't implement the metadata property and raise NotImplementedError. Wrap metadata access in try-except to gracefully handle this case and maintain backward compatibility. Fixes CI test failure in test_retrieval_job_dataframe.py
6dc5107 to
a6bbfda
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #6099 - Ensures offline retrieval honors ODFV feature projection, matching online retrieval behavior.
Problem
When requesting a subset of features from an OnDemandFeatureView:
This caused schema mismatches between training and serving pipelines.
Solution
Modified
RetrievalJob.to_arrow()inoffline_store.pyto:metadata.featuresExample
Before this fix:
After this fix:
Changes
Modified:
sdk/python/feast/infra/offline_stores/offline_store.pyRetrievalJob.to_arrow()method (lines 140-184)Added: Test in
sdk/python/tests/integration/offline_store/test_universal_historical_retrieval.pytest_odfv_projection()- Comprehensive test verifying:full_feature_names=TrueandFalseTesting
The new test
test_odfv_projectionverifies:Backward Compatibility
Impact
This fix ensures: