Skip to content

Commit 0c12655

Browse files
fix: Clean up version history on delete and use write_engine consistently
- delete_feature_view now also deletes version history records, preventing IntegrityError when re-creating a previously deleted FV - _get_next_version_number uses write_engine instead of read_engine to avoid stale version numbers with read replicas Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f035e96 commit 0c12655

File tree

1 file changed

+8
-1
lines changed
  • sdk/python/feast/infra/registry

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ def delete_feature_view(self, name: str, project: str, commit: bool = True):
561561
)
562562
if deleted_count == 0:
563563
raise FeatureViewNotFoundException(name, project)
564+
# Clean up version history for the deleted feature view
565+
with self.write_engine.begin() as conn:
566+
stmt = delete(feature_view_version_history).where(
567+
feature_view_version_history.c.feature_view_name == name,
568+
feature_view_version_history.c.project_id == project,
569+
)
570+
conn.execute(stmt)
564571

565572
def delete_feature_service(self, name: str, project: str, commit: bool = True):
566573
return self._delete_object(
@@ -992,7 +999,7 @@ def _proto_class_for_type(self, fv_type: str):
992999
raise ValueError(f"Unknown feature view type: {fv_type}")
9931000

9941001
def _get_next_version_number(self, name: str, project: str) -> int:
995-
with self.read_engine.begin() as conn:
1002+
with self.write_engine.begin() as conn:
9961003
stmt = select(
9971004
func.coalesce(
9981005
func.max(feature_view_version_history.c.version_number) + 1, 0

0 commit comments

Comments
 (0)