如何在spark中将字符串存储2018-03-21 08:15:00 +03:00为a timestamptype,保留UTC偏移量?
下面尝试过
from pyspark.sql.functions import *
df = spark.createDataFrame([("2018-03-21 08:15:00 +03:00",)], ["timestamp"])
newDf= df.withColumn("newtimestamp", to_timestamp(col('timestamp'), "yyyy-MM-dd HH:mm:ss XXX")
)
Run Code Online (Sandbox Code Playgroud)
此打印newtimestamp列的值转换为 UTC 时间,即2018-03-21 05:15:00
我如何将此字符串存储为数据帧中的时间戳列,保留偏移量,即将相同的字符串存储为时间戳或类似存储2018-03-21 08:15:00 +3000