将 Spark Dataframe 写入 ORC 会给出错误的时区
Writing Spark Dataframe to ORC gives the wrong timezone
每当我将 Dataframe 写入 ORC 时,Timestamp 字段的时区都不正确。
这是我的代码 -
// setting the timezone
val schema = List(
StructField("name", StringType),
StructField("date", TimestampType)
)
val data = Seq(
Row("test", java.sql.Timestamp.valueOf("2021-03-15 10:10:10.0"))
)
val df = spark.createDataFrame(
spark.sparkContext.parallelize(data),
StructType(schema)
)
// changing the timezone
spark.conf.set("spark.sql.session.timeZone", "MDT")
// value of the df has changed accordingly
df.show // prints 2021-03-15 08:10:10
// writing to orc
df.write.mode(SaveMode.Overwrite).format("orc").save("/tmp/dateTest.orc/")
ORC 文件中的值将为 2021-03-15 10:10:10.0.
有什么办法可以控制作者所在的时区吗?我在这里错过了什么吗?
提前致谢!
经过大量调查,这是 ORC 不支持的 (ATM)。不过,它支持 csv。
每当我将 Dataframe 写入 ORC 时,Timestamp 字段的时区都不正确。 这是我的代码 -
// setting the timezone
val schema = List(
StructField("name", StringType),
StructField("date", TimestampType)
)
val data = Seq(
Row("test", java.sql.Timestamp.valueOf("2021-03-15 10:10:10.0"))
)
val df = spark.createDataFrame(
spark.sparkContext.parallelize(data),
StructType(schema)
)
// changing the timezone
spark.conf.set("spark.sql.session.timeZone", "MDT")
// value of the df has changed accordingly
df.show // prints 2021-03-15 08:10:10
// writing to orc
df.write.mode(SaveMode.Overwrite).format("orc").save("/tmp/dateTest.orc/")
ORC 文件中的值将为 2021-03-15 10:10:10.0.
有什么办法可以控制作者所在的时区吗?我在这里错过了什么吗? 提前致谢!
经过大量调查,这是 ORC 不支持的 (ATM)。不过,它支持 csv。