将 Spark fileoutputcommitter.algorithm.version=2 与 AWS Glue 结合使用

Use Spark fileoutputcommitter.algorithm.version=2 with AWS Glue

我还没弄明白,但我正在尝试将直接输出提交器与 AWS Glue 结合使用:

spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version=2

是否可以将此配置与 AWS Glue 一起使用?

选项 1:

Glue 使用 spark 上下文,您也可以将 hadoop 配置设置为 aws glue。因为内部动态帧是一种数据帧。

sc._jsc.hadoopConfiguration().set("mykey","myvalue")

我认为你需要添加相应的 class 也喜欢这样

sc._jsc.hadoopConfiguration().set("mapred.output.committer.class", "org.apache.hadoop.mapred.FileOutputCommitter")

示例片段:

 sc = SparkContext()

    sc._jsc.hadoopConfiguration().set("mapreduce.fileoutputcommitter.algorithm.version","2")

    glueContext = GlueContext(sc)
    spark = glueContext.spark_session

证明那个配置存在....

在python中调试:

sc._conf.getAll() // print this

在 scala 中调试:

sc.getConf.getAll.foreach(println)

选项2:

对方你试试用胶水的job参数:

https://docs.aws.amazon.com/glue/latest/dg/add-job.html 它具有文档中提到的键值属性

'--myKey' : 'value-for-myKey'  

您可以按照下面的屏幕截图来编辑作业并使用 --conf

指定参数

选项 3:
如果您使用的是 aws cli,您可以在下面尝试... https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html

有趣的是,他们在文档中提到 不要设置 消息,如下所示。但是不知道为什么会暴露

To sum up : I personally prefer option1 since you have programmatic control.

转到粘合作业控制台并按如下方式编辑您的作业:

Glue> Jobs > Edit your Job> Script libraries and job parameters (optional) > Job parameters

设置如下:

key: --conf value:

spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version=2