@@ -303,32 +303,46 @@ def add_glue_catalog_id(params: Dict[str, str], **kwargs: Any) -> None:
303303
304304
305305class GlueCatalog (MetastoreCatalog ):
306- def __init__ (self , name : str , ** properties : Any ):
307- super ().__init__ (name , ** properties )
306+ glue : GlueClient
308307
309- retry_mode_prop_value = get_first_property_value (properties , GLUE_RETRY_MODE )
308+ def __init__ (self , name : str , client : Optional [GlueClient ] = None , ** properties : Any ):
309+ """Glue Catalog.
310310
311- session = boto3 .Session (
312- profile_name = properties .get (GLUE_PROFILE_NAME ),
313- region_name = get_first_property_value (properties , GLUE_REGION , AWS_REGION ),
314- botocore_session = properties .get (BOTOCORE_SESSION ),
315- aws_access_key_id = get_first_property_value (properties , GLUE_ACCESS_KEY_ID , AWS_ACCESS_KEY_ID ),
316- aws_secret_access_key = get_first_property_value (properties , GLUE_SECRET_ACCESS_KEY , AWS_SECRET_ACCESS_KEY ),
317- aws_session_token = get_first_property_value (properties , GLUE_SESSION_TOKEN , AWS_SESSION_TOKEN ),
318- )
319- self .glue : GlueClient = session .client (
320- "glue" ,
321- endpoint_url = properties .get (GLUE_CATALOG_ENDPOINT ),
322- config = Config (
323- retries = {
324- "max_attempts" : properties .get (GLUE_MAX_RETRIES , MAX_RETRIES ),
325- "mode" : retry_mode_prop_value if retry_mode_prop_value in EXISTING_RETRY_MODES else STANDARD_RETRY_MODE ,
326- }
327- ),
328- )
311+ You either need to provide a boto3 glue client, or one will be constructed from the properties.
312+
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 )
319+
320+ if client :
321+ self .glue = client
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+ )
329343
330- if glue_catalog_id := properties .get (GLUE_ID ):
331- _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 )
332346
333347 def _convert_glue_to_iceberg (self , glue_table : TableTypeDef ) -> Table :
334348 properties : Properties = glue_table ["Parameters" ]
0 commit comments