0
我努力学习Spark和我使用如下的unix_timestamp
函数读取数据帧与时间戳列:读一个完整的时间戳为数据帧
val columnName = "TIMESTAMPCOL"
val sequence = Seq(2016-01-20 12:05:06.999)
val dataframe = {
sequence.toDF(columnName)
}
val typeDataframe = dataframe.withColumn(columnName, org.apache.spark.sql.functions.unix_timestamp($"TIMESTAMPCOL"))
typeDataframe.show
这将产生一个输出:
+------------+
|TIMESTAMPCOL|
+------------+
| 1453320306|
+------------+
我如何阅读它,以便我不会丢失ms,即.999
部分?我尝试使用unix_timestamp(col: Col, s: String)
,其中s是SimpleDateFormat,例如“yyyy-MM-dd hh:mm:ss”,没有任何运气。
'date_format'使用Java SimpleDateFormat的内部,所以你会得到充分的时间以毫秒秒为好。可能重复[of](http://stackoverflow.com/questions/41879125/handling-microseconds-in-spark-scala/41879869#41879869) –
[Spark Scala中处理微秒](http:// stackoverflow。 COM /问题/ 41879125 /处理微秒功能于火花阶) –