Skip to content

feat: Add online append for sequence feature views - #7215

Open
patelchaitany wants to merge 2 commits into
feast-dev:masterfrom
patelchaitany:feat/squence-write
Open

patelchaitany wants to merge 2 commits into
feast-dev:masterfrom
patelchaitany:feat/squence-write

Conversation

@patelchaitany

@patelchaitany patelchaitany commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

#6848 added OnlineConfig, so a feature view can be set to mode="sequence" with write_mode="append". But every online write still went through online_write_batch, which keeps only the latest value per entity. This PR adds the write path that keeps every event.

  • New OnlineStore API. online_append and online_append_async take the same rows as online_write_batch. The default implementations raise NotImplementedError, so other stores keep working and fail clearly only when a feature view uses append mode.
  • Redis implementation. One sorted set per entity key and feature view:
    • Key: seq:<feature view>: followed by the entity's existing hash key.
    • Member: the event time as an 8-byte big-endian integer of microseconds, followed by the row's feature values as a serialized feast.types.Map. Each event is its own member, even when its values repeat an earlier event, so a late, older event can't move or trim a newer one. Writing the same event time and values again adds nothing.
    • Score: the event time in microseconds since the epoch (exact as a Redis score).
    • Rows are grouped by key, so each key gets one ZADD per batch. All keys go in one non-transactional pipeline.
  • Retention. After each ZADD, ZREMRANGEBYSCORE drops events older than max_age, then ZREMRANGEBYRANK keeps the newest max_length. key_ttl_seconds applies to these keys the same way it does to the hash keys. The trim is not atomic with the write, so readers should read at most max_length events.
  • Routing. PassthroughProvider.ingest_df and ingest_df_async (used by write_to_online_store and push) call online_append when the feature view's online_config.write_mode is "append", and online_write_batch otherwise. Feature views without online_config behave exactly as before.

Out of scope (follow-up PRs)

  • feast materialize for sequence-mode feature views.
  • Reading sequences back (online_read_sequence) and get_online_features support.
  • Online stores other than Redis. They inherit the base methods.
  • delete_table and teardown don't remove the seq: keys yet.

Which issue(s) this PR fixes:

Part of RHOAIENG-80117 (online append). Follows #6848.

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

New tests:

  • tests/unit/infra/online_store/test_online_store_base.py: online_append and online_append_async raise NotImplementedError by default.
  • tests/unit/infra/online_store/test_redis.py: every value for an entity is kept in its sorted set; the max_length and max_age trims are issued after the ZADD; the async path uses the async Redis client; a late, older event with the same values, in the same batch or a later write, doesn't move the newer event's time, so the max_age trim keeps it.
  • tests/unit/test_online_config_apply.py: write_to_online_store calls online_append for an append-mode feature view and online_write_batch otherwise.

The related unit suites pass (60 passed). ruff and scoped mypy on the changed modules are clean.


Devin Review

Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
@patelchaitany
patelchaitany requested review from a team as code owners November 23, 2026 08:21
@patelchaitany
patelchaitany requested review from nquinn408, ntkathole and tokoko and removed request for a team November 23, 2026 08:21

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

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

Devin Review

Comment on lines +783 to +787
pipe.zadd(redis_key_bin, events)
if cutoff is not None:
pipe.zremrangebyscore(redis_key_bin, "-inf", f"({cutoff}")
if max_length:
pipe.zremrangebyrank(redis_key_bin, 0, -(max_length + 1))

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.

🔴 Late duplicates erase newer sequence events

When identical feature values for an entity arrive newest first, online_append replaces the newer timestamp with the older one. Age or length trimming can then delete the entry even though the newer event qualified for retention.

Learn more

write_to_online_store routes append-mode DataFrames through ingest_df without sorting the rows. Redis stores one timestamp per sorted-set member, and _group_append_events uses only the feature values as the member. Within one batch, the last row with matching values wins; across batches, ZADD unconditionally replaces the existing score. The newer timestamp is lost in both cases, and the retention commands can then remove the remaining entry. online_append_async has the same behavior.

Example: At noon, write a value of 7 for entity 42 with an 11:55 event time and a one-hour age limit. Then append a delayed 10:00 event with the same value. Redis moves the entry to 10:00 and trims it, leaving no record of the 11:55 event. Submitting the two rows in that order in one batch has the same result.

Recommended fix: Include the event timestamp in the member identity so the older event can be trimmed independently. If retaining the payload-only format for now, keep the maximum timestamp in each batch and prevent Redis score updates from decreasing an existing score, using ZADD GT where supported. Cover newest-first inputs both within one batch and across writes.

Devin Review


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

@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 82.19178% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.14%. Comparing base (a291a0f) to head (a3cdeac).

Files with missing lines Patch % Lines
sdk/python/feast/infra/online_stores/redis.py 84.21% 4 Missing and 5 partials ⚠️
sdk/python/feast/infra/passthrough_provider.py 71.42% 1 Missing and 3 partials ⚠️
❗ 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    #7215      +/-   ##
==========================================
+ Coverage   54.10%   54.14%   +0.04%     
==========================================
  Files         467      467              
  Lines       58940    59011      +71     
  Branches     8688     8703      +15     
==========================================
+ Hits        31890    31953      +63     
- Misses      24892    24893       +1     
- Partials     2158     2165       +7     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.75% <82.19%> (+0.04%) ⬆️
Files with missing lines Coverage Δ
...k/python/feast/infra/online_stores/online_store.py 85.24% <100.00%> (+0.09%) ⬆️
sdk/python/feast/infra/passthrough_provider.py 62.85% <71.42%> (+1.24%) ⬆️
sdk/python/feast/infra/online_stores/redis.py 72.06% <84.21%> (+1.49%) ⬆️

... 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 a291a0f...a3cdeac. 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.

The sorted set member was only the serialized feature values, so two events
with the same values shared one member. A late, older event then moved that
member back to its own time, and the max_age trim could drop it, losing the
newer event. This happened within one batch (last row wins) and across
writes (ZADD replaces the score).

Prefix the member with the event time as an 8-byte big-endian integer of
microseconds. Each event is now its own member, and writing the same event
time and values again still adds nothing.

Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>

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.

2 participants