Skip to content

Commit e81f9eb

Browse files
committed
Add namespace check on rename_view
1 parent f67788c commit e81f9eb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎pyiceberg/catalog/rest/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,16 @@ def rename_view(self, from_identifier: Union[str, Identifier], to_identifier: Un
14801480
"source": self._split_identifier_for_json(from_identifier),
14811481
"destination": self._split_identifier_for_json(to_identifier),
14821482
}
1483+
1484+
# Ensure source and destination namespaces exist before rename.
1485+
source_namespace = self._split_identifier_for_json(from_identifier)["namespace"]
1486+
dest_namespace = self._split_identifier_for_path(to_identifier)["namespace"]
1487+
1488+
if not self.namespace_exists(source_namespace):
1489+
raise NoSuchNamespaceError(f"Source namespace does not exist: {source_namespace}")
1490+
if not self.namespace_exists(dest_namespace):
1491+
raise NoSuchNamespaceError(f"Destination namespace does not exist: {dest_namespace}")
1492+
14831493
response = self._session.post(self.url(Endpoints.rename_view), json=payload)
14841494
try:
14851495
response.raise_for_status()

0 commit comments

Comments
 (0)