【问题标题】:How to create dynamic data frame from S3 files in Glue Job in Scala?如何在 Scala 的 Glue Job 中从 S3 文件创建动态数据框?
【发布时间】:2019-10-12 16:26:35
【问题描述】:

我在将 Python Glue Job 转换为 Scala Glue Job 时遇到问题,即create_dynamic_data_frame_options 方法。在python中的语法是:

dyf = glueContext.create_dynamic_frame_from_options("s3",
                                        {'paths': file_paths},
                                         format="csv",
                                       format_options={"separator": ",", "quoteChar": '"'})

其中 file_paths 是一个列表 ['s3://bucket1/file1.txt','s3://bucket2/file2.txt'] 。如何在 Scala 中做同样的事情?

【问题讨论】:

    标签: scala amazon-web-services apache-spark etl aws-glue


    【解决方案1】:

    试试这个:

    val file_paths = Array(
        "s3://bucket/data1",
        "s3://bucket/data2"
    )
    
    val dyf = glueContext.getSourceWithFormat(
        connectionType = "s3", 
        options = JsonOptions(Map("paths" -> file_paths)), 
        format = "csv", 
        formatOptions = JsonOptions(Map("separator" -> ",", "quoteChar": "\""))
    ).getDynamicFrame()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-29
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多