Skip to content

Support creating a GlueCatalog with own client. #1910

Description

@rchowell

Feature Request / Improvement

Sometimes I have my own boto3 client which I would like to use as the GlueCatalog client. Perhaps an optional client constructor parameter or an alternative constructor can address this.

classGlueCatalog(MetastoreCatalog):
def__init__(self, name: str, client: GlueClient|None=None, **properties: Any):
super().__init__(name, **properties)
retry_mode_prop_value=get_first_property_value(properties, GLUE_RETRY_MODE)
ifclient:
self.glue=clientelse:
session=boto3.Session(
profile_name=properties.get(GLUE_PROFILE_NAME),
region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION),
botocore_session=properties.get(BOTOCORE_SESSION),
aws_access_key_id=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID),
aws_secret_access_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY),
aws_session_token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN),
)
self.glue: GlueClient=session.client(
"glue",
endpoint_url=properties.get(GLUE_CATALOG_ENDPOINT),
config=Config(
retries={
"max_attempts": properties.get(GLUE_MAX_RETRIES, MAX_RETRIES),
"mode": retry_mode_prop_valueifretry_mode_prop_valueinEXISTING_RETRY_MODESelseSTANDARD_RETRY_MODE,
}
),
)

Currently I am using __new__ to set this myself, but perhaps poor practice, and it's not clear at the moment which missing properties may impact me later.

gc=GlueCatalog.__new__(GlueCatalog)
gc.name=my_namegc.properties= {}
gc.glue=my_client# <-----

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions