@@ -623,9 +623,12 @@ def _get_privilege(self, table: Table, locations: dict[str, str], mounts: list[M
623623
624624 def _get_database_grants (self , tables : list [Table ], principals : list [str ]) -> list [Grant ]:
625625 databases = {table .database for table in tables }
626- return [
627- Grant (principal , "USAGE" , "hive_metastore" , database ) for database in databases for principal in principals
628- ]
626+ grants = []
627+ for database in databases :
628+ for principal in principals :
629+ grant = Grant (principal , "USAGE" , "hive_metastore" , database )
630+ grants .append (grant )
631+ return grants
629632
630633 def _get_grants (
631634 self , locations : dict [str , str ], principals : list [str ], tables : list [Table ], mounts : list [Mount ]
@@ -635,33 +638,21 @@ def _get_grants(
635638 for table in tables :
636639 privilege = self ._get_privilege (table , locations , mounts )
637640 if privilege == "READ_FILES" :
638- grants .extend (
639- [Grant (principal , "SELECT" , table .catalog , table .database , table .name ) for principal in principals ]
640- )
641+ for principal in principals :
642+ grants .append (Grant (principal , "SELECT" , table .catalog , table .database , table .name ))
641643 filtered_tables .append (table )
642644 continue
643645 if privilege == "WRITE_FILES" :
644- grants .extend (
645- [
646- Grant (principal , "ALL PRIVILEGES" , table .catalog , table .database , table .name )
647- for principal in principals
648- ]
649- )
646+ for principal in principals :
647+ grants .append (Grant (principal , "ALL PRIVILEGES" , table .catalog , table .database , table .name ))
650648 filtered_tables .append (table )
651649 continue
652650 if table .view_text is not None :
653- grants .extend (
654- [
655- Grant (principal , "ALL PRIVILEGES" , table .catalog , table .database , view = table .name )
656- for principal in principals
657- ]
658- )
651+ for principal in principals :
652+ grants .append (Grant (principal , "ALL PRIVILEGES" , table .catalog , table .database , view = table .name ))
659653 filtered_tables .append (table )
660-
661654 database_grants = self ._get_database_grants (filtered_tables , principals )
662-
663655 grants .extend (database_grants )
664-
665656 return grants
666657
667658 def _get_cluster_principal_mapping (self , cluster_id : str , object_type : str ) -> list [str ]:
0 commit comments