![](/img/trans.png)
[英]Loading parquet file from S3 to AWS RDS taking extremely long time using AWS Glue ETL
[英]Load partitioned json files from S3 in AWS Glue ETL jobs
我正在尝试在 S3 存储中加载 json 个这样分区的文件:
|-json-data
|-x=something
|-y=something
|-data.json
我在我的 ETL 工作中像这样加载它们
datasource0 = glueContext.create_dynamic_frame_from_options('s3',
{
'paths': ['s3://bucket/json-data/'],
'recurse': True,
'groupFiles': 'inPartition',
'partitionKeys':['x', 'y']
},
format='json',
transformation_ctx = 'datasource0')
但是,当我尝试使用datasource0.printSchema()
读取模式时,模式中没有任何分区。 我需要在模式中有这些分区来进行转换。 经过一些研究,我不确定这是否是create_dynamic_frame_from_options
的支持功能。 有人知道怎么做吗?
您只能在 write_dynamic_frame.from_options 中传递 partitionKey,而不能在从 s3 读取时传递。要加载特定分区或过滤它们,您需要这些分区已经存在于源代码中。
因此,您需要使用 Glue 爬虫进行爬虫,或者在 Athena 中使用分区创建表。 一旦表在 Glue 元数据中可用,您就可以将表的分区加载到 Glue ETL 中,如下所示:
glue_context.create_dynamic_frame.from_catalog(
database = "my_S3_data_set",
table_name = "catalog_data_table",
push_down_predicate = my_partition_predicate)
请参考以下链接了解如何利用谓词下推:
https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-partitions.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.