feat: Add feature view versioning support to MongoDB online store - #6774
Open
alekseevpavel04 wants to merge 2 commits into
Open
feat: Add feature view versioning support to MongoDB online store#6774alekseevpavel04 wants to merge 2 commits into
alekseevpavel04 wants to merge 2 commits into
Conversation
MongoDB raised VersionedOnlineReadNotSupported for any version-qualified reference, so feature view versioning could not be used on MongoDB at all. Unlike the stores that already support this, MongoDB keeps one collection per project and stores each feature view inside it as a sub-document key, under features.<fv> and event_timestamps.<fv>. Versioning the collection name would split one entity's document across collections and duplicate every vector index, so the version qualifies the document namespace instead, following redis.py rather than sqlite.py. Adds _versioned_fv_name() and applies it on the write path, both read paths, the document converter, the vector search path, update(), and the Atlas vector index names and paths, so each version gets its own index. teardown() is unchanged: it drops the whole collection. Also registers MongoDBOnlineStore in the allow-list consulted by OnlineStore._is_versioned_read_supported(), without which a versioned read still raises regardless of what the store does. With versioning disabled the document keys are byte-for-byte what they were, and the two new parameters both default to the previous behaviour. Signed-off-by: Pavel Alekseev <alekceevpavel@mail.ru>
Milvus has been in the allow-list consulted by OnlineStore._is_versioned_read_supported() since versioned reads were added to it, but was never added to the sentence VersionedOnlineReadNotSupported prints, which tells the user which stores do support them. The message therefore names a store set smaller than reality. Signed-off-by: Pavel Alekseev <alekceevpavel@mail.ru>
alekseevpavel04
requested review from
HaoXuAI,
nquinn408 and
tokoko
and removed request for
a team
August 22, 2026 14:20
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6774 +/- ##
==========================================
+ Coverage 47.09% 47.18% +0.09%
==========================================
Files 419 419
Lines 51878 51890 +12
Branches 7525 7525
==========================================
+ Hits 24430 24483 +53
+ Misses 25700 25654 -46
- Partials 1748 1753 +5
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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.
What this PR does / why we need it:
Adds feature view versioning to the MongoDB online store, so version-qualified
references such as
driver_stats@v2:trips_todayread and write the right data.Until now MongoDB raised
VersionedOnlineReadNotSupportedfor any versionedreference, so versioning could not be used on MongoDB at all.
One deliberate departure from the issue, which points at
sqlite.py. SQLite,PostgreSQL, MySQL, FAISS, DynamoDB and Milvus all give each feature view its own
table or collection, so versioning there is a matter of appending
_v{N}to thattable name via
compute_table_id(). MongoDB is not shaped that way: it keepsone collection per project (
{project}_{collection_suffix}) and stores eachfeature view inside it as a sub-document key — values under
features.<fv>.<feature>, the per-view timestamp underevent_timestamps.<fv>.Applying the
sqlite.pypattern literally would give each version its owncollection, which splits a single entity's document across collections — an
unversioned read of another feature view on the same entity would stop working —
and duplicates every Atlas vector index.
So this follows
redis.pyinstead, which is the only existing store with the sameshape (its feature view name is a key namespace rather than a table, and it uses
compute_versioned_name()rather thancompute_table_id()). Concretely it adds amodule-level
_versioned_fv_name(table, config)wrapping the sharedcompute_versioned_name()helper, and applies it everywhere the feature view nameis used as a namespace:
_build_write_ops— shared by the sync and async write pathsonline_read/online_read_async— the projection_convert_raw_docs_to_proto— reading the values back outretrieve_online_documents_v2— the vector path, the Atlas index name, and the$vectorSearchfilter prefixupdate— the$unsetfor deleted feature views_ensure_vector_indexes/_drop_vector_indexes_for_tables— index names andtheir
path, so each version gets its own vector indexteardownis unchanged: it drops the whole collection, so every version goes withit.
MongoDBOnlineStoreis also added to the allow-list inOnlineStore._is_versioned_read_supported()— without that entry a versioned readstill raises regardless of what the store does.
Behaviour with versioning off is unchanged.
compute_versioned_name()returnsthe bare name unless
registry.enable_online_feature_view_versioningis set and anon-zero version is present, so existing deployments write and read exactly the
same document keys as before. The two new parameters (
fv_nameon_convert_raw_docs_to_proto,enable_versioningon the two vector-index helpers)both default to the previous behaviour, so existing callers are unaffected.
One adjacent change: the
VersionedOnlineReadNotSupportedmessage lists thestores that support versioned reads, and it was already out of date — Milvus is in
the allow-list but was missing from the sentence. Rather than add MongoDB to a
list that is wrong, this corrects the whole list. Happy to drop the Milvus half if
you would rather keep this to one thing.
Which issue(s) this PR fixes:
Fixes #6178
Checks
git commit -s)Testing Strategy
New file
sdk/python/tests/unit/infra/online_store/test_mongodb_versioning.py,24 tests following the shape of the existing
test_redis_versioning.py:projection.version_tagwinning over
current_version_numberdifferent ones
table.namewhenno name is passed, and reporting "not found" for a version never written
updateunsetting only the deleted version's namespaceMongoDBOnlineStorepassing_check_versioned_read_supportWith the versioning applied but reverted at the call sites, 10 of the 24 fail and
the 14 that pass are the unversioned-behaviour cases, which is the intended split.
Full
sdk/python/tests/unitrun matches the pre-change baseline with the 24 newtests added and nothing else changed.
No integration test: this is namespace construction throughout, and exercising it
end to end needs a live MongoDB/Atlas, which the unit suite does not have.
Misc
The remaining ten sibling issues under #2728 (Bigtable, Datastore, Snowflake,
Couchbase, Elasticsearch, Hazelcast, HBase, Hybrid, Qdrant, Remote) are untouched
here. Happy to take another if this shape looks right to you.