glue etl 作业 - 使用 create_dynamic_frame.from_options 获取 s3 子文件夹

Jos*_*hua 6 python amazon-web-services apache-spark pyspark aws-glue

我正在创建 AWS Glue ETL 作业,但在文件检索方面遇到了一些障碍。

看来以下代码仅获取根文件夹 2017 中的文件,而不再获取其他文件。有什么方法可以包含其中的所有子文件夹和文件吗?

dyf = glueContext.create_dynamic_frame.from_options(
    's3',
    {"paths": [
        's3://bucket/2017/'
        ]},
    "json",
    transformation_ctx = "dyf")

Run Code Online (Sandbox Code Playgroud)

Jos*_*hua 6

找到了这个问题的解决方案,看起来字典接受更多参数,我需要的是“递归”。您还可以使用“排除”排除某些模式。

来源https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-connect.html#aws-glue-programming-etl-connect-s3

dyf = glueContext.create_dynamic_frame.from_options(
    's3',
    {
        "paths": [
            's3://bucket/2017/'
        ],
        "recurse" : True
    },
    "json",
    transformation_ctx = "dyf")

Run Code Online (Sandbox Code Playgroud)