【发布时间】:2019-03-25 09:02:19
【问题描述】:
假设我的 spark 数据框中有一个非常规日期:
val df = Seq("24-12-2017","25-01-2016").toDF("dates")
df.show()
+----------+
| dates|
+----------+
|24-12-2017|
|25-01-2016|
然后我想将这些日期解析为时间戳,但它不起作用:
import java.text.SimpleDateFormat
def fmt(d:String) = {
val f = new SimpleDateFormat("dd-MM-yyyy")
f.parse(d)
}
val reFormat = udf(fmt(_:String):Timestamp)
cmd15.sc:1: not found: type Timestamp
val reFormat = udf{fmt(_:String):Timestamp}
我错过了什么?任何帮助表示赞赏!!!
【问题讨论】:
标签: scala apache-spark user-defined-functions