-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Feast apply silently ignoring ttl updates to None or timedelta(0) #6709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ntkathole
merged 4 commits into
feast-dev:master
from
saket3395:fix/ttl-clear-falsy-guard
Aug 14, 2026
+67
−10
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
73d3956
fix: feast apply ignores ttl updates when new ttl is None or timedelt…
326215c
address review nitpicks: hoist Duration import, guard FromTimedelta
cc340e8
test: cover ttl clearing in _update_metadata_fields (#6703)
b34897a
style: apply ruff format to registry.py ttl block
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
sdk/python/tests/unit/infra/registry/test_update_metadata_fields.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Unit tests for Registry._update_metadata_fields TTL handling (issue #6703). | ||
|
|
||
| Re-applying a FeatureView with its ttl cleared to ``None`` or | ||
| ``timedelta(0)`` (both the documented ways to express "no ttl") used to be | ||
| silently dropped, because the update was gated on ``updated_fv.ttl`` being | ||
| truthy -- and both of those values are falsy. | ||
|
|
||
| ``_update_metadata_fields`` does not use any instance state, so it is exercised | ||
| directly via the class here rather than standing up a full registry backend. | ||
| """ | ||
|
|
||
| from datetime import timedelta | ||
|
|
||
| import pytest | ||
|
|
||
| from feast.entity import Entity | ||
| from feast.feature_view import FeatureView | ||
| from feast.field import Field | ||
| from feast.infra.offline_stores.file_source import FileSource | ||
| from feast.infra.registry.registry import Registry | ||
| from feast.types import Float32 | ||
|
|
||
|
|
||
| def _feature_view(ttl): | ||
| return FeatureView( | ||
| name="fv", | ||
| entities=[Entity(name="e", join_keys=["e_id"])], | ||
| schema=[Field(name="f1", dtype=Float32)], | ||
| source=FileSource(path="file://feast/*", timestamp_field="ts_col"), | ||
| ttl=ttl, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("cleared_ttl", [None, timedelta(0)]) | ||
| def test_update_metadata_fields_clears_ttl(cleared_ttl): | ||
| existing_proto = _feature_view(timedelta(days=10)).to_proto() | ||
| # sanity: the existing view starts with a finite ttl | ||
| assert existing_proto.spec.ttl.ToNanoseconds() != 0 | ||
|
|
||
| updated_fv = _feature_view(cleared_ttl) | ||
| Registry._update_metadata_fields(None, existing_proto, updated_fv) | ||
|
|
||
| # the cleared ttl (None / timedelta(0)) must now be reflected as "no ttl" | ||
| assert existing_proto.spec.ttl.ToNanoseconds() == 0 | ||
|
|
||
|
|
||
| def test_update_metadata_fields_preserves_finite_ttl(): | ||
| existing_proto = _feature_view(timedelta(days=10)).to_proto() | ||
|
|
||
| updated_fv = _feature_view(timedelta(days=3)) | ||
| Registry._update_metadata_fields(None, existing_proto, updated_fv) | ||
|
|
||
| assert existing_proto.spec.ttl.ToTimedelta() == timedelta(days=3) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] Consider error handling for invalid timedelta
FromTimedelta could potentially raise an exception for invalid timedelta values. Consider adding basic validation or error handling to provide better user feedback.
Suggested: