Skip to content

Commit 66c55e3

Browse files
LuisFigueroaGntkathole
authored andcommitted
fix: Refresh the SQL registry cache after deleting a data source
Signed-off-by: LuisFigueroaG <[email protected]>
1 parent 11a47b4 commit 66c55e3

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

‎sdk/python/feast/infra/registry/sql.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,14 +1089,13 @@ def apply_feature_service(
10891089
)
10901090

10911091
def delete_data_source(self, name: str, project: str, commit: bool = True):
1092-
with self.write_engine.begin() as conn:
1093-
stmt = delete(data_sources).where(
1094-
data_sources.c.data_source_name == name,
1095-
data_sources.c.project_id == project,
1096-
)
1097-
rows = conn.execute(stmt)
1098-
if rows.rowcount < 1:
1099-
raise DataSourceObjectNotFoundException(name, project)
1092+
return self._delete_object(
1093+
data_sources,
1094+
name,
1095+
project,
1096+
"data_source_name",
1097+
DataSourceObjectNotFoundException,
1098+
)
11001099

11011100
def _list_feature_services(
11021101
self, project: str, tags: Optional[dict[str, str]], **kwargs

‎sdk/python/tests/unit/infra/registry/test_sql_registry.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
from feast import Field
2626
from feast.data_source import PushSource
2727
from feast.entity import Entity
28-
from feast.errors import ConflictingFeatureViewNames, PermissionNotFoundException
28+
from feast.errors import (
29+
ConflictingFeatureViewNames,
30+
DataSourceObjectNotFoundException,
31+
PermissionNotFoundException,
32+
)
2933
from feast.feature_view import FeatureView
3034
from feast.infra.offline_stores.file_source import FileSource
3135
from feast.infra.registry.sql import (
@@ -381,6 +385,25 @@ def test_delete_entity_refreshes_cache(sqlite_registry):
381385
assert sqlite_registry.list_entities("test_project", allow_cache=True) == []
382386

383387

388+
def test_delete_data_source_refreshes_cache(sqlite_registry):
389+
source = FileSource(
390+
name="driver_stats",
391+
path="driver_stats.parquet",
392+
timestamp_field="event_timestamp",
393+
)
394+
sqlite_registry.apply_data_source(source, "test_project")
395+
assert [
396+
ds.name
397+
for ds in sqlite_registry.list_data_sources("test_project", allow_cache=True)
398+
] == ["driver_stats"]
399+
400+
sqlite_registry.delete_data_source("driver_stats", "test_project")
401+
402+
assert sqlite_registry.list_data_sources("test_project", allow_cache=True) == []
403+
with pytest.raises(DataSourceObjectNotFoundException):
404+
sqlite_registry.delete_data_source("driver_stats", "test_project")
405+
406+
384407
def _build_feature_view(name: str, entity: Entity, source: FileSource) -> FeatureView:
385408
return FeatureView(
386409
name=name,

0 commit comments

Comments
 (0)