Skip to content

Commit a634bea

Browse files
committed
Add namespace check on rename_view
1 parent 7b4a4f5 commit a634bea

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
@@ -885,6 +885,16 @@ def rename_view(self, from_identifier: Union[str, Identifier], to_identifier: Un
885885
"source": self._split_identifier_for_json(from_identifier),
886886
"destination": self._split_identifier_for_json(to_identifier),
887887
}
888+
889+
# Ensure source and destination namespaces exist before rename.
890+
source_namespace = self._split_identifier_for_json(from_identifier)["namespace"]
891+
dest_namespace = self._split_identifier_for_path(to_identifier)["namespace"]
892+
893+
if not self.namespace_exists(source_namespace):
894+
raise NoSuchNamespaceError(f"Source namespace does not exist: {source_namespace}")
895+
if not self.namespace_exists(dest_namespace):
896+
raise NoSuchNamespaceError(f"Destination namespace does not exist: {dest_namespace}")
897+
888898
response = self._session.post(self.url(Endpoints.rename_view), json=payload)
889899
try:
890900
response.raise_for_status()

0 commit comments

Comments
 (0)