2828from pypaimon .catalog .catalog import Catalog
2929from pypaimon .catalog .catalog_context import CatalogContext
3030from pypaimon .catalog .catalog_environment import CatalogEnvironment
31- from pypaimon .catalog .catalog_utils import check_not_branch , check_not_system_table
31+ from pypaimon .catalog .catalog_utils import check_not_branch , check_not_system_database , check_not_system_table
3232from pypaimon .catalog .catalog_exception import (
3333 ColumnAlreadyExistException , ColumnNotExistException ,
3434 TableNotExistException , DatabaseAlreadyExistException ,
@@ -164,6 +164,7 @@ def list_databases_paged(self, max_results: Optional[int] = None, page_token: Op
164164
165165 def create_database (self , name : str , ignore_if_exists : bool ,
166166 properties : Optional [Dict [str , str ]] = None ) -> None :
167+ check_not_system_database (name )
167168 try :
168169 self .rest_api .create_database (name , properties )
169170 except AlreadyExistsException as e :
@@ -187,6 +188,7 @@ def get_database(self, name: str) -> Database:
187188 raise DatabaseNoPermissionException (name ) from e
188189
189190 def drop_database (self , name : str , ignore_if_not_exists : bool = False , cascade : bool = False ) -> None :
191+ check_not_system_database (name )
190192 if not cascade :
191193 try :
192194 tables = self .list_tables (name )
@@ -209,6 +211,7 @@ def drop_database(self, name: str, ignore_if_not_exists: bool = False, cascade:
209211 raise DatabaseNoPermissionException (name ) from e
210212
211213 def alter_database (self , name : str , changes : List [PropertyChange ]) -> None :
214+ check_not_system_database (name )
212215 try :
213216 set_properties , remove_keys = PropertyChange .get_set_properties_to_remove_keys (changes )
214217 self .rest_api .alter_database (name , list (remove_keys ), set_properties )
0 commit comments