1

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
  • 485
  • 3
  • 7
  • 18

2 Answers2

6

Try this,

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

You can use :

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