Skip to content

Commit 8ee3da5

Browse files
committed
Add namespace check on rename_view
1 parent cf4a2b8 commit 8ee3da5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,16 @@ def rename_view(self, from_identifier: Union[str, Identifier], to_identifier: Un
13251325
"source": self._split_identifier_for_json(from_identifier),
13261326
"destination": self._split_identifier_for_json(to_identifier),
13271327
}
1328+
1329+
# Ensure source and destination namespaces exist before rename.
1330+
source_namespace = self._split_identifier_for_json(from_identifier)["namespace"]
1331+
dest_namespace = self._split_identifier_for_path(to_identifier)["namespace"]
1332+
1333+
if not self.namespace_exists(source_namespace):
1334+
raise NoSuchNamespaceError(f"Source namespace does not exist: {source_namespace}")
1335+
if not self.namespace_exists(dest_namespace):
1336+
raise NoSuchNamespaceError(f"Destination namespace does not exist: {dest_namespace}")
1337+
13281338
response = self._session.post(self.url(Endpoints.rename_view), json=payload)
13291339
try:
13301340
response.raise_for_status()

0 commit comments

Comments
 (0)