Repository navigation
fix: Stop Ray retrieval from using a request column as the point-in-time cutoff - #7214
iammanoj807 wants to merge 1 commit into
Conversation
…ime cutoff When the entity dataframe has a column named like a feature view's source timestamp field, the Ray offline store joined on that name for both sides, so the request's values became the point-in-time cutoff. Feature values came back missing or from after the event timestamp, and non-timestamp values lost rows. Join on an unused internal column name in that case: rename the source timestamp to it, add the entity side's copy of event_timestamp under it, and drop it after the join. The request column is left unchanged. Without a collision, the code path is the same as before. Remove the Ray xfail from the universal test added in feast-dev#7177 and add Ray tests for datetime, integer and string request columns. Fixes feast-dev#7190 Signed-off-by: Manoj Kumar Thapa <iammanoj807@gmail.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7214 +/- ##
==========================================
- Coverage 53.94% 53.92% -0.02%
==========================================
Files 466 466
Lines 58822 58840 +18
Branches 8665 8668 +3
==========================================
+ Hits 31729 31730 +1
- Misses 24954 24972 +18
+ Partials 2139 2138 -1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Devin Review found 1 potential issue.
5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| result_ds, | ||
| feature_df, | ||
| join_keys, | ||
| timestamp_field, | ||
| join_timestamp_field, | ||
| requested_feats, | ||
| full_feature_names, | ||
| fv.projection.name_to_use(), |
There was a problem hiding this comment.
🔴 Shared cutoff drops distinct requests
After the cutoff switch, broadcast_join_features drops all but one same-batch request sharing an entity key and event timestamp. This happens when merge_asof succeeds, even if distinct values in the colliding request column previously kept the rows separate.
(Refers to this code)
Learn more
Each entity dataframe row is a separate request for historical features and can carry its own request data. The new collision path copies event_timestamp to the join key instead of using the colliding request column as that key. For small sources, broadcast entity deduplication keeps only the last row per entity key and join timestamp in each batch. A successful merge_asof receives that reduced batch, so the other requests never reach the result. The manual fallback uses the original cleaned batch instead and does not exhibit this particular row loss.
Example: Request features for driver 1 twice at Jan 3, with request IDs 101 and 102 and request ts values of Jan 2 and Jan 4. A small source with one row for driver 1 at Jan 1 takes the successful broadcast merge path. Before this change both IDs survived; now only 102 survives. Both IDs need the Jan 1 feature value.
Recommended fix: Keep the entity rows intact for the collision path when calling merge_asof. Leave source-side deduplication in place. Add a regression test with two request IDs, identical entity keys and event timestamps, different colliding request values, and a source ordered so that merge_asof succeeds.
Was this helpful? React with 👍 or 👎 to provide feedback.
What this PR does / why we need it:
In the Ray offline store,
get_historical_featuresjoins each feature view on one timestamp column name for both sides: the source'stimestamp_field. When the entity dataframe has no column of that name, it first adds a copy ofevent_timestampunder it. When the entity dataframe already has such a column (request data that happens to share the name), the copy is skipped, so the broadcast join, the windowed join and the manual fallback all use the request's values as the point-in-time cutoff. As a result (#7190):This PR joins on an internal column name when the request has a column named like the source timestamp field: the source's timestamp is renamed to that name, the entity side gets its copy of
event_timestampunder it, and it is dropped after the join. The request's column is left as it is. The internal name comes from a small_unused_column_namehelper, the same approach #7177 used for the file (Dask) store. Without a collision, the code path is unchanged.Tests:
test_historical_features_with_request_column_named_like_timestamp_field(added in fix: Keep the source event timestamp separate from request data in Dask retrieval #7177), so the universal test now runs as a normal test on Ray.sdk/python/tests/component/ray/test_ray_timestamp_field_collision.py, which CI's Ray job runs: a request column named like the source timestamp field holding datetimes, integers or strings, with both settings offull_feature_names. It checks the latest value at or before each event timestamp and that the request column comes back unchanged. On master, all 6 fail: with datetimes, a value from after the event timestamp and a missing one; with integers, missing feature values; with strings, one row instead of three.Which issue(s) this PR fixes:
Fixes #7190
Checks
git commit -s)Testing Strategy
Misc
Run locally (Python 3.11, Ray 2.58.0):
sdk/python/tests/integration/offline_store, as in theray-testspixi task): 54 passed and 5 skipped. On master: 52 passed, 5 skipped and the 2 xfailed cases of this test.sdk/python/tests/component/ray): 83 passed, which is master's 77 plus the 6 new tests. With--integration: 14 passed, the same as master.deltalake, no Docker).ray.py.tests/component/ray/rather thantests/unit/: Ray is installed only for Python 3.11 in the unit-test CI, and the unit job runs with-n 8, while the Ray job runs this folder throughtest-unit-compute-ray.get_historical_featurescalls per side on 80 random datasets.broadcast_join_threshold_mb: -1);ts, or one ontsand one onts2), afield_mappingontots, ajoin_key_mapthrough a feature service, with and without a created column, bothfull_feature_namessettings;ts(collision) orreq_value(control);ts, andentity_df=None.req_value(minus the copy ofevent_timestampthat Ray adds astsin that case). Master differed in 1,033 of them.join_key_mapraise the same error on master and this branch; that's separate from this change.