Skip to content

fix: Stop Ray retrieval from using a request column as the point-in-time cutoff - #7214

Open
iammanoj807 wants to merge 1 commit into
feast-dev:masterfrom
iammanoj807:fix/ray-timestamp-field-request-column
Open

iammanoj807 wants to merge 1 commit into
feast-dev:masterfrom
iammanoj807:fix/ray-timestamp-field-request-column

Conversation

@iammanoj807

@iammanoj807 iammanoj807 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

In the Ray offline store, get_historical_features joins each feature view on one timestamp column name for both sides: the source's timestamp_field. When the entity dataframe has no column of that name, it first adds a copy of event_timestamp under 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):

  • feature values come back missing, or from after the event timestamp (expected 20/20, got 30/NA);
  • a request column of that name holding integers or strings is parsed as timestamps, so rows are lost or come back without feature values, and the column itself can come back as 1970 timestamps; with strings the result can even be empty, with no error.

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_timestamp under 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_name helper, the same approach #7177 used for the file (Dask) store. Without a collision, the code path is unchanged.

Tests:

  • Removes the strict Ray xfail from 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.
  • Adds 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 of full_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

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

Run locally (Python 3.11, Ray 2.58.0):

  • Ray universal offline store integration tests (sdk/python/tests/integration/offline_store, as in the ray-tests pixi task): 54 passed and 5 skipped. On master: 52 passed, 5 skipped and the 2 xfailed cases of this test.
  • Ray component tests (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.
  • The edited universal test on the file and DuckDB stores: 2/2 each. DuckDBDelta and the remote offline stores can't run locally (no deltalake, no Docker).
  • ruff 0.16.10 passes on the changed files; mypy reports no new errors in ray.py.
  • The new tests are in tests/component/ray/ rather than tests/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 through test-unit-compute-ray.
  • Manual check: the reproducer from Ray offline store uses an entity dataframe column named like the source timestamp field as the point-in-time cutoff #7190, on master and this branch (Ray now gives 20/20, like DuckDB).
  • Randomised comparison against master: 3,309 get_historical_features calls per side on 80 random datasets.
    • Inputs:
      • both join paths (the windowed join forced with broadcast_join_threshold_mb: -1);
      • one or two feature views (both on ts, or one on ts and one on ts2), a field_mapping onto ts, a join_key_map through a feature service, with and without a created column, both full_feature_names settings;
      • request columns holding UTC and naive datetimes, integers, floats, strings or only nulls, named ts (collision) or req_value (control);
      • an entity dataframe whose event column is itself ts, and entity_df=None.
    • The 1,920 calls without a collision gave identical results (values, dtypes, column order) on master and this branch.
    • In all 1,389 calls with a collision, this branch returned the same result as the same request with the column named req_value (minus the copy of event_timestamp that Ray adds as ts in that case). Master differed in 1,033 of them.
    • 281 windowed-join calls with a join_key_map raise the same error on master and this branch; that's separate from this change.

Devin Review

…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>
@iammanoj807
iammanoj807 requested a review from a team as a code owner November 23, 2026 05:29
@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.92%. Comparing base (3ece12f) to head (f39e9ee).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ra/offline_stores/contrib/ray_offline_store/ray.py 0.00% 20 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.51% <0.00%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
...ra/offline_stores/contrib/ray_offline_store/ray.py 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ece12f...f39e9ee. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines 2579 to 2585
result_ds,
feature_df,
join_keys,
timestamp_field,
join_timestamp_field,
requested_feats,
full_feature_names,
fv.projection.name_to_use(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ray offline store uses an entity dataframe column named like the source timestamp field as the point-in-time cutoff

2 participants