I have a Spark dataframe with datetime column in format yyyy-MM-dd HH:mm:SS.
My dataframe looks like below:
| datetime_column | output_column |
|---|---|
| 2021-01-29 21:30:00 | 2021-01-30 00:00:00 |
| 2021-01-30 05:30:00 | 2021-01-30 00:00:00 |
| 2021-01-01 23:25:00 | 2021-01-02 00:00:00 |
| 2021-01-02 08:59:59 | 2021-01-02 00:00:00 |
How would I be able to get the output_column column from datetime_column column using Spark SQL?
NOTE: My data (datetime_column) will always be present between 9 PM to 9 AM so finding the nearest midnight is straightforward.
I am using PySpark 2.4.6