res.show(false)
+---+-------------------+-------------------+-----------------------+--------------+
|id |date |timestamp |current_timestamp() |current_date()|
+---+-------------------+-------------------+-----------------------+--------------+
|1 |2014/01/01 23:00:01|2014-01-01 23:00:01|2020-05-20 23:29:16.471|2020-05-20 |
|1 |2014/11/31 12:40:32|null |2020-05-20 23:29:16.471|2020-05-20 |
|1 |2016/12/29 09:54:00|2016-12-29 09:54:00|2020-05-20 23:29:16.471|2020-05-20 |
|1 |2016/05/09 10:12:43|2016-05-09 10:12:43|2020-05-20 23:29:16.471|2020-05-20 |
+---+-------------------+-------------------+-----------------------+--------------+
Convert string date into TimestampType in Spark SQL
Convert the date as string into timestamp (including time zone) using
unix_timestamp
and cast it asTimestampType
. Note that you might need to convert with a specific timezone.Last refresh: Never