我有一个用例,在使用 awswrangler 时,我需要为 amazonglue 指定自定义端点(vpc 端点)。
研究源代码后,我发现 AWS Data Wrangler 使用配置对象
config
来创建客户端,可通过 from awswrangler._config import config 进行访问。该对象具有每个 AWS 服务的名为 service_name_endpoint_url 的属性(glue_endpoint_url、athena_endpoint_url 等)。如果这些属性不是“无”,则它们用于为特定服务创建客户端。幸运的是,该对象为这些属性提供了设置器。我可以将此对象导入到我的代码中并设置glue_endpoint_url。因此,在我的应用程序代码中:
from awswrangler._config import config
config.glue_endpoint_url = "https://vpce-***********.glue.eu-east-1.vpce.amazonaws.com"
wr.s3.to_parquet(
df=df,
path=GLUE_S3_PATH,
dataset=True,
database=GLUE_DATABASE,
partition_cols=partition_cols,
table=GLUE_TABLE_NAME,
dtype=athena_schema,
mode=mode,
)