Spark Dataframe连接字符串

时间:2018-07-11 10:45:29

标签: scala apache-spark

如何使用Spark-Scala连接日期和时间列(两个字符串)

+---+-------------------+-----+
| ID|   Date            |Time
+---+------------------ +-----+
|  G|2014.01.14 00:00:00| 1:00
+---+-------------------+------

"2014.01.14 1:00" 

2 个答案:

答案 0 :(得分:1)

尝试一下,

result.withColumn("Date && Time", concat(regexp_replace(col("date"),"00:00:00",""), lit(""), (col("time"))))

答案 1 :(得分:0)

您可以使用:

result.withColumn("Date && Time", concat(col("Date"), lit(""), (col("Time")) ));