0

How to concatenate Date and Time column (both string) using Spark-Scala

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

"2014.01.14 1:00" 
milad ahmadi
  • 395
  • 3
  • 6
  • 17

2 Answers2

5

Try this,

result.withColumn("Date && Time", concat(regexp_replace(col("date"),"00:00:00",""), lit(""), (col("time"))))
William R
  • 719
  • 2
  • 13
  • 33
1

You can use :

result.withColumn("Date && Time", concat(col("Date"), lit(""), (col("Time")) ));
YohanT
  • 72
  • 1
  • 9