将 Spark Dataframe 写入 ORC 给出了错误的时区

问题描述

每当我将数据帧写入 ORC 时,时间戳字段的时区都不正确。 这是我的代码 -

// 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。