将sparkDataframe写入orc时给出了错误的时区

qyswt5oh  于 2021-07-14  发布在  Spark
关注(0)|答案(1)|浏览(220)

每当我将Dataframe写入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。
有没有办法控制作者的时区?我是不是漏了什么?提前谢谢!

50pmv0ei

50pmv0ei1#

所以经过大量调查,这是orc不支持的(atm)。不过,csv支持它。

相关问题