Repository navigation
fix: Keep the new event range of an overwritten SavedDataset #7212
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
Open
ShivamSharma43
wants to merge
3
commits into
feast-dev:master
Choose a base branch
from
ShivamSharma43:fix/saved-dataset-timestamps
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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
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
78 changes: 78 additions & 0 deletions
78
sdk/python/tests/unit/infra/registry/test_saved_dataset_timestamps.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,78 @@ | ||
| """Unit tests for the timestamps of a SavedDataset that is re-applied.""" | ||
|
|
||
| from datetime import datetime, timezone | ||
|
|
||
| import pytest | ||
|
|
||
| from feast.infra.offline_stores.file_source import SavedDatasetFileStorage | ||
| from feast.infra.registry.registry import Registry | ||
| from feast.repo_config import RegistryConfig | ||
| from feast.saved_dataset import SavedDataset | ||
|
|
||
| PROJECT = "test_project" | ||
|
|
||
|
|
||
| def _day(day): | ||
| return datetime(2026, 1, day) | ||
|
|
||
|
|
||
| def _saved_dataset(min_event_timestamp=None, max_event_timestamp=None): | ||
| dataset = SavedDataset( | ||
| name="ds", | ||
| features=["fv:f1"], | ||
| join_keys=["e_id"], | ||
| storage=SavedDatasetFileStorage(path="ds.parquet"), | ||
| ) | ||
| dataset.min_event_timestamp = min_event_timestamp | ||
| dataset.max_event_timestamp = max_event_timestamp | ||
| return dataset | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def registry(tmp_path): | ||
| config = RegistryConfig(path=str(tmp_path / "registry.db"), cache_ttl_seconds=0) | ||
| return Registry(PROJECT, config, None) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("tzinfo", [None, timezone.utc]) | ||
| def test_reapplied_saved_dataset_stores_its_new_event_range(registry, tzinfo): | ||
| registry.apply_saved_dataset(_saved_dataset(_day(1), _day(3)), PROJECT) | ||
| registry.apply_saved_dataset( | ||
| _saved_dataset( | ||
| _day(11).replace(tzinfo=tzinfo), _day(13).replace(tzinfo=tzinfo) | ||
| ), | ||
| PROJECT, | ||
| ) | ||
|
|
||
| stored = registry.get_saved_dataset("ds", PROJECT) | ||
| assert stored.min_event_timestamp == _day(11) | ||
| assert stored.max_event_timestamp == _day(13) | ||
|
|
||
|
|
||
| def test_reapplied_saved_dataset_without_event_range_keeps_the_stored_one(registry): | ||
| registry.apply_saved_dataset(_saved_dataset(_day(1), _day(3)), PROJECT) | ||
| registry.apply_saved_dataset(_saved_dataset(), PROJECT) | ||
|
|
||
| stored = registry.get_saved_dataset("ds", PROJECT) | ||
| assert stored.min_event_timestamp == _day(1) | ||
| assert stored.max_event_timestamp == _day(3) | ||
|
|
||
|
|
||
| def test_reapplied_saved_dataset_does_not_invent_an_event_range(registry): | ||
| registry.apply_saved_dataset(_saved_dataset(), PROJECT) | ||
| registry.apply_saved_dataset(_saved_dataset(), PROJECT) | ||
|
|
||
| stored = registry.get_saved_dataset("ds", PROJECT) | ||
| assert stored.min_event_timestamp is None | ||
| assert stored.max_event_timestamp is None | ||
|
|
||
|
|
||
| def test_saved_dataset_stores_last_updated_timestamp(registry): | ||
| registry.apply_saved_dataset(_saved_dataset(_day(1), _day(3)), PROJECT) | ||
| first = registry.get_saved_dataset("ds", PROJECT) | ||
| assert first.last_updated_timestamp is not None | ||
|
|
||
| registry.apply_saved_dataset(_saved_dataset(_day(1), _day(3)), PROJECT) | ||
| second = registry.get_saved_dataset("ds", PROJECT) | ||
| assert second.created_timestamp == first.created_timestamp | ||
| assert second.last_updated_timestamp >= first.last_updated_timestamp |
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
Oops, something went wrong.
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.
🟡 Dataset preview errors after metadata edits
When a user edits a registered dataset with no event bounds,
apply_saved_datasetleaves both bounds unset. The saved dataset reader requires both, so the preview returns HTTP 500 instead of an empty result.Learn more
Register Dataset registers existing storage without supplying event timestamps, and Edit Dataset sends the same registration request with overwrite enabled. Before this change, editing a registration with no bounds replaced them with epoch timestamps, so the file offline store could execute the preview query, albeit with the wrong range. The new behavior keeps the bounds absent, but retrieve_saved_dataset still converts the lower bound and adds a second to the upper bound unconditionally. The preview endpoint turns the resulting exception into HTTP 500.
Example: Register a Parquet file containing January 2026 rows, then edit only the dataset description and open the sample tab. Before this change, the sample request succeeded with zero rows because it filtered near the epoch. It now fails before querying the file.
Recommended fix: Keep absent bounds absent in the registry. Make
PassthroughProvider.retrieve_saved_datasethandle missing bounds explicitly, translating them to unbounded reads where supported. The Dask file store already skips the corresponding filters. Add a regression test for previewing an edited registration without event bounds.Was this helpful? React with 👍 or 👎 to provide feedback.
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.
Fixed in 457ac39.
PassthroughProvider.retrieve_saved_datasetnow passes a missingmin_event_timestampormax_event_timestamptopull_all_from_table_or_queryasNoneinstead of converting it, so a dataset without an event range is read unbounded on that side. The bounds that are set are handled as before (tz-aware, one second added to the upper one).Tests added:
test_saved_dataset_preview_without_event_range_via_restregisters a Parquet file over REST, edits it withallow_override, checks no range is stored, and readsGET /saved_datasets/data/{name}(3 rows; returned 500 before the change).test_retrieve_saved_dataset_leaves_missing_event_bounds_openintests/unit/infra/test_provider.pycovers no bounds, either bound, and both.