Can unix_timestamp() return unix time in milliseconds in Apache Spark?

前端 未结 4 1654
情深已故
情深已故 2021-02-12 20:17

I\'m trying to get the unix time from a timestamp field in milliseconds (13 digits) but currently it returns in seconds (10 digits).

scala> var df = Seq(\"20         


        
4条回答
  •  礼貌的吻别
    2021-02-12 21:21

    Milliseconds hide in fraction part timestamp format

    Try this:

    df = df.withColumn("time_in_milliseconds", col("time").cast("double"))
    

    You'll get something like 1484758800.792, where 792 it's milliseconds

    At least it's works for me (Scala, Spark, Hive)

提交回复
热议问题