Skip to content

Commit ced933e

Browse files
committed
Add namespace check on rename_view
1 parent 53f4326 commit ced933e

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
@@ -1332,6 +1332,16 @@ def rename_view(self, from_identifier: Union[str, Identifier], to_identifier: Un
13321332
"source": self._split_identifier_for_json(from_identifier),
13331333
"destination": self._split_identifier_for_json(to_identifier),
13341334
}
1335+
1336+
# Ensure source and destination namespaces exist before rename.
1337+
source_namespace = self._split_identifier_for_json(from_identifier)["namespace"]
1338+
dest_namespace = self._split_identifier_for_path(to_identifier)["namespace"]
1339+
1340+
if not self.namespace_exists(source_namespace):
1341+
raise NoSuchNamespaceError(f"Source namespace does not exist: {source_namespace}")
1342+
if not self.namespace_exists(dest_namespace):
1343+
raise NoSuchNamespaceError(f"Destination namespace does not exist: {dest_namespace}")
1344+
13351345
response = self._session.post(self.url(Endpoints.rename_view), json=payload)
13361346
try:
13371347
response.raise_for_status()

0 commit comments

Comments
 (0)