在 AWS Glue 3.0 中使用 1900 年之前的时间戳编写镶木地板时出现问题

问题描述 投票:0回答:5

从 Glue 2.0 切换到 3.0 时,也就是从 Spark 2.4 切换到 3.1.1 时, 在处理 1900 年之前的时间戳时,我的工作开始失败并出现此错误:

An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
You may get a different result due to the upgrading of Spark 3.0: reading dates before 1582-10-15 or timestamps before 1900-01-01T00:00:00Z from Parquet INT96 files can be ambiguous, 
as the files may be written by Spark 2.x or legacy versions of Hive, which uses a legacy hybrid calendar that is different from Spark 3.0+s Proleptic Gregorian calendar.
See more details in SPARK-31404.
You can set spark.sql.legacy.parquet.int96RebaseModeInRead to 'LEGACY' to rebase the datetime values w.r.t. the calendar difference during reading. 
Or set spark.sql.legacy.parquet.int96RebaseModeInRead to 'CORRECTED' to read the datetime values as it is.

我尝试了一切以在 Glue 中设置

int96RebaseModeInRead
配置,甚至联系了支持人员,但似乎目前 Glue 正在覆盖该标志,您无法自己设置它。

如果有人知道解决方法,那就太好了。否则我将继续使用 Glue 2.0。并等待 Glue 开发团队解决这个问题。

amazon-web-services apache-spark pyspark aws-glue
5个回答
24
投票

我通过将

--conf
设置为
spark.sql.legacy.parquet.int96RebaseModeInRead=CORRECTED --conf spark.sql.legacy.parquet.int96RebaseModeInWrite=CORRECTED --conf spark.sql.legacy.parquet.datetimeRebaseModeInRead=CORRECTED --conf spark.sql.legacy.parquet.datetimeRebaseModeInWrite=CORRECTED
使其工作。

虽然没有预计到达时间,但这是一种解决方法,Glue 开发团队正在努力修复。

此外,这仍然是非常有问题的。例如,您不能在

.show()
上调用
DynamicFrame
,您需要在
DataFrame
上调用它。另外我所有的工作都失败了,我打电话给
data_frame.rdd.isEmpty()
,不要问我为什么。

2021 年 11 月 24 日更新: 我联系了 Glue 开发团队,他们告诉我这是修复它的预期方法。不过,有一个可以在脚本内部完成的解决方法:

sc = SparkContext()
# Get current sparkconf which is set by glue
conf = sc.getConf()
# add additional spark configurations
conf.set("spark.sql.legacy.parquet.int96RebaseModeInRead", "CORRECTED")
conf.set("spark.sql.legacy.parquet.int96RebaseModeInWrite", "CORRECTED")
conf.set("spark.sql.legacy.parquet.datetimeRebaseModeInRead", "CORRECTED")
conf.set("spark.sql.legacy.parquet.datetimeRebaseModeInWrite", "CORRECTED")
# Restart spark context
sc.stop()
sc = SparkContext.getOrCreate(conf=conf)
# create glue context with the restarted sc
glueContext = GlueContext(sc)

7
投票

官方 Glue 开发人员指南中解决的问题

从 AWS Glue 2.0 迁移到 AWS Glue 3.0 最后一个项目符号。


2
投票

从 spark 版本 3.2 开始,

spark.sql.legacy.parquet.*
已弃用。

2023-04-03 21:27:13.362 thread=main, log_level=WARN , [o.a.s.s.internal.SQLConf], The SQL config 'spark.sql.legacy.parquet.datetimeRebaseModeInRead' has been deprecated in Spark v3.2 and may be removed in the future. Use 'spark.sql.parquet.datetimeRebaseModeInRead' instead.

所以需要使用下面的火花配置:

conf.set("spark.sql.parquet.int96RebaseModeInRead", "CORRECTED")
conf.set("spark.sql.parquet.int96RebaseModeInWrite", "CORRECTED")
conf.set("spark.sql.parquet.datetimeRebaseModeInRead", "CORRECTED")
conf.set("spark.sql.parquet.datetimeRebaseModeInWrite", "CORRECTED")

0
投票

在某些情况下,作业甚至可能在正确设置所需配置的情况下失败。 例如,读取数据帧然后调用 .rdd 方法时会失败。 问题在于,在某些情况下,当使用 Glue API 读取数据并将 DynamicDataFrame 作为输出时,它将在内部使用 RDD API。 这段代码失败了,因为所需的标志没有传播到执行阶段。

为了解决这个问题,我们还用

包装了这段代码
SqlExecution.withSQLConfPropagated{
   glueContext.getSource(...).getDynamicFrame
}

然后所需的 SQL 配置将正确传播到执行阶段并将被考虑在内。


0
投票

我尝试应用相同的解决方案,它在中间对我有用。有时它会运行,有时会抛出以下错误 异常:调用 o316.parquet 时出错。

我们尝试了几个选项,但对我们没有任何作用,每当我们尝试进行多次运行时,它就会抛出错误,你能帮忙解决这个问题吗

© www.soinside.com 2019 - 2024. All rights reserved.