@@ -305,36 +305,44 @@ def add_glue_catalog_id(params: Dict[str, str], **kwargs: Any) -> None:
305305class GlueCatalog (MetastoreCatalog ):
306306 glue : GlueClient
307307
308- def __init__ (self , name : str , client : GlueClient | None = None , ** properties : Any ):
309- super ().__init__ (name , ** properties )
308+ def __init__ (self , name : str , client : Optional [GlueClient ] = None , ** properties : Any ):
309+ """Glue Catalog.
310+
311+ You either need to provide a boto3 glue client, or one will be constructed from the properties.
310312
311- retry_mode_prop_value = get_first_property_value (properties , GLUE_RETRY_MODE )
313+ Args:
314+ name: Name to identify the catalog.
315+ client: An optional boto3 glue client.
316+ properties: Properties for glue client construction and configuration.
317+ """
318+ super ().__init__ (name , ** properties )
312319
313320 if client :
314321 self .glue = client
315- return
316-
317- session = boto3 .Session (
318- profile_name = properties .get (GLUE_PROFILE_NAME ),
319- region_name = get_first_property_value (properties , GLUE_REGION , AWS_REGION ),
320- botocore_session = properties .get (BOTOCORE_SESSION ),
321- aws_access_key_id = get_first_property_value (properties , GLUE_ACCESS_KEY_ID , AWS_ACCESS_KEY_ID ),
322- aws_secret_access_key = get_first_property_value (properties , GLUE_SECRET_ACCESS_KEY , AWS_SECRET_ACCESS_KEY ),
323- aws_session_token = get_first_property_value (properties , GLUE_SESSION_TOKEN , AWS_SESSION_TOKEN ),
324- )
325- self .glue : GlueClient = session .client (
326- "glue" ,
327- endpoint_url = properties .get (GLUE_CATALOG_ENDPOINT ),
328- config = Config (
329- retries = {
330- "max_attempts" : properties .get (GLUE_MAX_RETRIES , MAX_RETRIES ),
331- "mode" : retry_mode_prop_value if retry_mode_prop_value in EXISTING_RETRY_MODES else STANDARD_RETRY_MODE ,
332- }
333- ),
334- )
322+ else :
323+ retry_mode_prop_value = get_first_property_value (properties , GLUE_RETRY_MODE )
324+
325+ session = boto3 .Session (
326+ profile_name = properties .get (GLUE_PROFILE_NAME ),
327+ region_name = get_first_property_value (properties , GLUE_REGION , AWS_REGION ),
328+ botocore_session = properties .get (BOTOCORE_SESSION ),
329+ aws_access_key_id = get_first_property_value (properties , GLUE_ACCESS_KEY_ID , AWS_ACCESS_KEY_ID ),
330+ aws_secret_access_key = get_first_property_value (properties , GLUE_SECRET_ACCESS_KEY , AWS_SECRET_ACCESS_KEY ),
331+ aws_session_token = get_first_property_value (properties , GLUE_SESSION_TOKEN , AWS_SESSION_TOKEN ),
332+ )
333+ self .glue : GlueClient = session .client (
334+ "glue" ,
335+ endpoint_url = properties .get (GLUE_CATALOG_ENDPOINT ),
336+ config = Config (
337+ retries = {
338+ "max_attempts" : properties .get (GLUE_MAX_RETRIES , MAX_RETRIES ),
339+ "mode" : retry_mode_prop_value if retry_mode_prop_value in EXISTING_RETRY_MODES else STANDARD_RETRY_MODE ,
340+ }
341+ ),
342+ )
335343
336- if glue_catalog_id := properties .get (GLUE_ID ):
337- _register_glue_catalog_id_with_glue_client (self .glue , glue_catalog_id )
344+ if glue_catalog_id := properties .get (GLUE_ID ):
345+ _register_glue_catalog_id_with_glue_client (self .glue , glue_catalog_id )
338346
339347 def _convert_glue_to_iceberg (self , glue_table : TableTypeDef ) -> Table :
340348 properties : Properties = glue_table ["Parameters" ]
0 commit comments